我正在使用jQuery數據表來顯示客戶記錄。我第一次進入客戶頁面時,我有20個客戶記錄dataTable按 排序客戶ID列(因此它們從20到1開始,其中20是第20位客戶的ID,第1位是第一位客戶的ID)desc 訂購。第20位客戶顯示在dataTable的頂部。如何在列排序後從jquery dataTable中獲取正確的行數據?
現在如果做低於我的javascript代碼
var customerTable=$('#customer').dataTable();// where customer is the html div associated with dataTable
var custData = customerTable.fnGetData(18)// it gives me data of 19 row in dataTable(as dataTable index starts from 0)
// so i get the data of customer having customer id=19
完全沒有到這裏。
現在我單擊customerId列上的排序圖標。因此,在對客戶進行ID分類之後,在dataTable中顯示1,ID爲20的客戶將顯示在底部。現在我做我的JavaScript調度研究再次
var customerTable=$('#customer').dataTable();
var custData = customerTable.fnGetData(18)
// it should give me data for customer id=2 Right? but still i am getting the old data i.e customer Data having id=19.
我沒有得到我爲什麼不選後得到正確的數據?在dataTable 排序後,我應該如何獲得正確的數據和行ID?
你可以在datatables.net查看這個討論 - http://datatables.net/forums/discussion/13315/fngetdata-does-not-return-the-data-in-right-order-after-column-排序在jQuery數據表#Item_6 –