Tabulator 4.5 从 api 获取数据但不使用数据渲染 table

Tabulator 4.5 get data from api but do not render the table with data

在模态上下文中,Tabulator 从 api 获取数据但不呈现 table。

如果我在 return json 之前从 api 开始睡眠 500 毫秒,数据就会显示出来。

<div class="form-group">
 <div id="tablePersonnages"></div>
</div>

<script type="text/javascript">

var table = new Tabulator("#tablePersonnages",({
    pagination: "local",
    paginationSize: 10,
    history: true,
    ajaxURL: '@Url.Action("ObtenirPersonnages", "FicheHistorique")',
    ajaxParams: { idFiche: '@Model' },
    ajaxConfig: "POST",
    layout: "fitColumns",       
    locale: true,
    langs: {
        "fr-fr": {

            "ajax": {
                "loading": "Chargement", //ajax loader text
                "error": "Erreur" //ajax error text
            },

            "pagination": {
                "first": "Début", //text for the first page button
                "first_title": "Première page", //tooltip text for the first page button
                "last": "Fin",
                "last_title": "Dernière page",
                "prev": "Préc",
                "prev_title": "Page précédente",
                "next": "Suiv",
                "next_title": "Page suivante"
            }
        }
    },
    columns: [ //Define Table Columns

        { title: "Id", field: "Id", visible: false },
        { title: "Nom", field: "Nom", headerFilter: "input", headerFilterPlaceholder: " " },
        { title: "Prenom", field: "Prenom", headerFilter: "input", headerFilterPlaceholder: " " },
        { title: "Fonction", field: "Fonction", headerFilter: "input", headerFilterPlaceholder: " " },
        { title: "Naissance", field: "Naissance" },
        { title: "Deces", field: "Deces" },
        { formatter: link, width: 10 }
    ]

}));

在模态打开事件中

调用table.redraw(true) 如果仍然无效,请将重绘放入setTimeout()