fooplugins / FooTable

jQuery plugin to make HTML tables responsive
https://fooplugins.com/plugins/footable-jquery/
Other
2.13k stars 637 forks source link

Footable wait for loadRows(data) to display #852

Open ItsNotMyFault opened 5 years ago

ItsNotMyFault commented 5 years ago

I Fetch data with Ajax (works). I try to fill my table with the data, but I want for it to be displayed into my table before doing anything.

You can see im my code where the method test is waiting t obe done with his work before to display into the console "count done". However loadrows doesn't care.

  function LoadFootableRows(jsondata) {
            ftInventory.loadRows(jsondata);
        }
        function test(gg) {
            var tt = 0;
            for (var i = 0; i < gg; i++) {
                tt += i;
                console.log(tt);
            }
            console.log("final --- " + tt);
            return tt;
        }

function FillFooTable() { disableWhileProcessing(); var accountId = $('#ddlAccount').val(); var inventoryStatus = $('#ddlInventoryStatus').val(); var filter = $('#dialogAssetComputer_UserComputerName').val(); ShowModal(); $.ajax({ type: "POST", url: "/Asset/GetAssetComputerByAccount", data: { AccountId: accountId, inventoryStatus: inventoryStatus, Filter: filter }, datatype: "Json", success: function (jsondata) { enableAfterProcess(); $.when(test(9999)).then(function (result) { HideModal(); ModalSuccessShow(); console.log("count done?"); });

                    $.when(LoadFootableRows(jsondata)).then(function () {
                        HideModal();
                        ModalSuccessShow();
                            console.log("display data into table done?");
                    });

                    $('#dialogDetail_SelectedAccount').text($("#ddlAccount option:selected").text());
                    $('#dialogDetail_Filter').text($("#dialogAssetComputer_UserComputerName").val());
                    $('#dialogDetail_SelectedStatus').text($("#ddlInventoryStatus option:selected").text());
                },
                error: function () {
                    console.log("fonctionne pas");
                }
            });
    }

I want my footable to be filled so I can use some other function such as table.draw() or $(window).scrollTop(XXXnumber) Those works with a timeout function...