i'm using jquery , datatables in page, fetches data server , populates tables quite happily.
i need make change make sure requests datatables library fetch data server happen in defined order. need able trigger update (of tables in correct order) when want - need function trigger appropriate code.
i have 3 tables in page. i've tried adding table.fnreloadajax() call next table in callback method of first table, either seems trigger refresh on first 2 tables or not @ all.
i tried creating function call 3 seperate function call fnreloadajax() on each table in turn, being asynchronous order of requests server varies.
what i've tried, doesn't seem hoping. give indication of aims:
firsttable= $('#firstshipment').datatable({ "bserverside": true, ...<snip>... "fninfocallback": function (osettings, istart, iend, imax, itotal, spre) { secondtable.fnreloadajax(); } }); secondtable= $('#firstshipment').datatable({ "bserverside": true, ...<snip>... "fninfocallback": function (osettings, istart, iend, imax, itotal, spre) { thirdtable.fnreloadajax(); } }); thirdtable= $('#firstshipment').datatable({ "bserverside": true, ...<snip>... "fninfocallback": function (osettings, istart, iend, imax, itotal, spre) { //this last table, nothing on completion } });
i'd quite happy solution either defined in init of datatables (what i'm trying above) or separate function can call periodically force ordered update.
in order populate data in specific order , make synchonous, can perform data retrieval in 2 steps. 1st one, making synchronous ajax call using parameter async: false. see:
http://api.jquery.com/jquery.ajax/#jquery-ajax-settings
once have results, can populate data using javascript array datasource datatable. see:
http://datatables.net/release-datatables/examples/data_sources/js_array.html
i hope helps you.
Comments
Post a Comment