顧客レコードを表示するために jquery dataTable を使用しています。初めて顧客ページに移動すると、dataTable に customerId 列で並べ替えられた 20 の顧客レコードがあります (したがって、20 から 1 まで表示されます。ここで、20 は 20 番目の顧客の ID で、1 は最初の顧客の ID です)。20 番目の顧客が 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 が 1 の顧客を並べ替えた後、dataTable の上部に表示され、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 を使用して正しいデータを取得するにはどうすればよいですか?