使用rowcallback时,数据表行索引无法正常工作

时间:2019-04-30 16:09:55

标签: jquery datatables

使用分页时,表的列索引记录不匹配,并且fnRowCallback函数的'nRow'参数仅返回所选页面的可见记录,而不返回所有记录。

我附上问题的快照,以更好地理解。我已经尝试了DataTable中所说的大多数脚本,但是没有用。在分页中的页面之间切换时,带有索引的第一页映射不正确。

列数据是动态的,因此我为S.no创建了一个空列,以更新数据表中附加记录的索引。使用fnRowCallback时,索引在视图中可以正常工作。但是,当我尝试将表记录打印或导出为pdf时,记录的索引不匹配。

1st Time the indexing working fine when exporting the document

The picture showing Exported document which Index mismatch after switching over from from one page to another

df <- structure(list(ID = c("80865510", "80865510", "80865510", "80865510", 
"80865510", "80865510", "80865510", "80865510", "80865510", "80865510", 
"80865510", "80865510", "80865510", "80865510", "80865510", "80865510", 
"80865510", "80865510", "80865510", "80865510", "80865510", "80865510", 
"80865510", "80865510", "80865510", "80865510", "80865510", "80865510", 
"80865510", "80865510", "80865510", "80865510", "80865510", "80865510", 
"80865510", "80865510", "80865510", "80865510", "80865510", "80865510", 
"80865510", "80865510", "80865510", "80865510", "80865510", "80865510", 
"80865510", "80865510", "80865510", "80865510", "02581610", "02581610", 
"02581610", "02581610", "02581610", "02581610", "02581610", "02581610", 
"02581610", "02581610", "02581610", "02581610", "02581610", "02581610", 
"02581610", "02581610", "02581610", "02581610", "02581610", "02581610", 
"02581610", "02581610", "02581610", "02581610", "02581610", "02581610", 
"02581610", "02581610", "02581610", "02581610", "02581610", "02581610", 
"02581610", "02581610", "02581610", "02581610", "02581610", "02581610", 
"02581610", "02581610", "02581610", "02581610", "02581610", "02581610", 
"02581610", "02581610", "02581610", "02581610", "02581610", "02581610", 
"83269640", "83269640", "83269640", "83269640", "83269640", "83269640", 
"83269640", "83269640", "83269640", "83269640", "83269640", "83269640", 
"83269640", "83269640", "83269640", "83269640", "83269640", "83269640", 
"83269640", "83269640", "83269640", "83269640", "83269640", "83269640", 
"83269640", "83269640", "83269640", "83269640", "83269640", "83269640", 
"83269640", "83269640", "83269640", "83269640", "83269640", "83269640", 
"83269640", "83269640", "83269640", "83269640", "83269640", "83269640", 
"83269640", "83269640", "83269640", "83269640", "83269640", "83269640", 
"83269640", "83269640", "69351T10", "69351T10", "69351T10", "69351T10", 
"69351T10", "69351T10", "69351T10", "69351T10", "69351T10", "69351T10", 
"69351T10", "69351T10", "69351T10", "69351T10", "69351T10", "69351T10", 
"69351T10", "69351T10", "69351T10", "69351T10", "69351T10", "69351T10", 
"69351T10", "69351T10", "69351T10", "69351T10", "69351T10", "69351T10", 
"69351T10", "69351T10", "69351T10", "69351T10", "69351T10", "69351T10", 
"69351T10", "69351T10", "69351T10", "69351T10", "69351T10", "69351T10", 
"69351T10", "69351T10", "69351T10", "69351T10", "69351T10", "69351T10", 
"69351T10", "69351T10", "69351T10", "69351T10", "60871R20", "60871R20", 
"60871R20", "60871R20", "60871R20", "60871R20", "60871R20", "60871R20", 
"60871R20", "60871R20", "60871R20", "60871R20", "60871R20", "60871R20", 
"60871R20", "60871R20", "60871R20", "60871R20", "60871R20", "60871R20", 
"60871R20", "60871R20", "60871R20", "60871R20", "60871R20", "60871R20", 
"60871R20", "60871R20", "60871R20", "60871R20", "60871R20", "60871R20", 
"60871R20", "60871R20", "60871R20", "60871R20", "60871R20", "60871R20", 
"60871R20", "60871R20", "60871R20", "60871R20", "60871R20", "60871R20", 
"60871R20", "60871R20", "60871R20", "60871R20", "60871R20", "60871R20", 
"83186520", "83186520", "83186520", "83186520", "83186520", "83186520", 
"83186520", "83186520", "83186520", "83186520", "83186520", "83186520", 
"83186520", "83186520", "83186520", "83186520", "83186520", "83186520", 
"83186520", "83186520", "83186520", "83186520", "83186520", "83186520", 
"83186520", "83186520", "83186520", "83186520", "83186520", "83186520", 
"83186520", "83186520", "83186520", "83186520", "83186520", "83186520", 
"83186520", "83186520", "83186520", "83186520", "83186520", "83186520", 
"83186520", "83186520", "83186520", "83186520", "83186520", "83186520", 
"83186520", "83186520"), date = structure(c(NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 16857, 16860, 
16861, 16862, 16863, 16864, 16867, 16868, 16869, 16870, 16871, 
16874, 16875, 16876, 16877, 16878, 16881, 16882, 16883, 16884, 
16888, 16889, 16890, 16891, 16892, 16895, 16896, 16897, 16898, 
16899, 16902, 16903, 16904, 16905, 16906, 16909, 16910, 16911, 
16912, 16913, 16916, 16917, 16918, 16919, 16920, 16923, 16924, 
16925, 16926, 16927, 16861, 16862, 16863, 16864, 16867, 16868, 
16869, 16870, 16871, 16874, 16875, 16876, 16877, 16878, 16881, 
16882, 16883, 16884, 16888, 16889, 16890, 16891, 16892, 16895, 
16896, 16897, 16898, 16899, 16902, 16903, 16904, 16905, 16906, 
16909, 16910, 16911, 16912, 16913, 16916, 16917, 16918, 16919, 
16920, 16923, 16924, 16925, 16926, 16927, 16930, 16931, 16860, 
16861, 16862, 16863, 16864, 16867, 16868, 16869, 16870, 16871, 
16874, 16875, 16876, 16877, 16878, 16881, 16882, 16883, 16884, 
16888, 16889, 16890, 16891, 16892, 16895, 16896, 16897, 16898, 
16899, 16902, 16903, 16904, 16905, 16906, 16909, 16910, 16911, 
16912, 16913, 16916, 16917, 16918, 16919, 16920, 16923, 16924, 
16925, 16926, 16927, 16930, 17130, 17133, 17134, 17135, 17136, 
17137, 17140, 17141, 17142, 17143, 17144, 17147, 17148, 17149, 
17150, 17151, 17154, 17155, 17156, 17157, 17158, 17162, 17163, 
17164, 17165, 17169, 17170, 17171, 17172, 17175, 17176, 17177, 
17178, 17179, 17183, 17184, 17185, 17186, 17189, 17190, 17191, 
17192, 17193, 17196, 17197, 17198, 17199, 17200, 17203, 17204, 
16853, 16854, 16855, 16856, 16857, 16860, 16861, 16862, 16863, 
16864, 16867, 16868, 16869, 16870, 16871, 16874, 16875, 16876, 
16877, 16878, 16881, 16882, 16883, 16884, 16888, 16889, 16890, 
16891, 16892, 16895, 16896, 16897, 16898, 16899, 16902, 16903, 
16904, 16905, 16906, 16909, 16910, 16911, 16912, 16913, 16916, 
16917, 16918, 16919, 16920, 16923), class = "Date"), price = c(NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, 55.3800010681152, 55.5800018310547, 56.7999992370605, 57.1199989318848, 
58.0900001525879, 58.2900009155273, 59, 59.4300003051758, 59.0499992370605, 
58.75, 59.4599990844727, 59.5699996948242, 59.2299995422363, 
59.7000007629395, 60.0800018310547, 61.2200012207031, 61.2099990844727, 
60.6100006103516, 60.6300010681152, 60.4700012207031, 60.2799987792969, 
60.5999984741211, 60.2900009155273, 61.4000015258789, 61.0999984741211, 
60.6199989318848, 60.189998626709, 59.8800010681152, 58.8600006103516, 
59.5, 59.7999992370605, 60.6800003051758, 62.1599998474121, 62.5099983215332, 
62.1399993896484, 62.5900001525879, 63.5699996948242, 65.0199966430664, 
65.6100006103516, 65.9300003051758, 65.6999969482422, 66.1999969482422, 
66.2300033569336, 65.8399963378906, 65.4300003051758, 65.6800003051758, 
64.8499984741211, 64.2600021362305, 63.9199981689453, 64.5100021362305, 
128.229995727539, 127.809997558594, 128.309997558594, 127.540000915527, 
126.800003051758, 126.209999084473, 127.069999694824, 128.490005493164, 
129.520004272461, 129.259994506836, 128.460006713867, 129.139999389648, 
129.910003662109, 128.850006103516, 128.339996337891, 127.699996948242, 
128.770004272461, 128.710006713867, 129.600006103516, 129.979995727539, 
130.179992675781, 129.839996337891, 132.520004272461, 127.569999694824, 
126.01000213623, 127.540000915527, 127.720001220703, 127.900001525879, 
127.779998779297, 127.970001220703, 128.220001220703, 127.400001525879, 
128.399993896484, 129.380004882812, 129.529998779297, 128.539993286133, 
124.580001831055, 126.150001525879, 127.430000305176, 127.309997558594, 
127.940002441406, 127.779998779297, 126.980003356934, 127.680000305176, 
126.819999694824, 128.149993896484, 128.380004882812, 129.270004272461, 
129.419998168945, 131.270004272461, 34.9900016784668, 34.8300018310547, 
34.9199981689453, 35.2599983215332, 35.6699981689453, 36.060001373291, 
35.9599990844727, 36.4599990844727, 36.5499992370605, 36.560001373291, 
36.3600006103516, 36.5099983215332, 36.9300003051758, 37.5699996948242, 
37.060001373291, 37.189998626709, 37.0099983215332, 37.060001373291, 
37.189998626709, 37.1699981689453, 37.5999984741211, 37.7000007629395, 
38.0699996948242, 38.189998626709, 38.0299987792969, 37.3300018310547, 
37.560001373291, 37.3600006103516, 37.4000015258789, 37.189998626709, 
37.4599990844727, 37.1100006103516, 37.0499992370605, 37.5400009155273, 
37.7299995422363, 37.7999992370605, 37.0499992370605, 36.2700004577637, 
36.5099983215332, 36.5499992370605, 36.4599990844727, 36.8600006103516, 
37.2700004577637, 37.6399993896484, 38.3499984741211, 38.0800018310547, 
38.3699989318848, 38.3199996948242, 38.2999992370605, 38.439998626709, 
99.7399978637695, 99.8300018310547, 100.050003051758, 98.0299987792969, 
94.6600036621094, 95.629997253418, 95.5299987792969, 95.4800033569336, 
97.129997253418, 98.1100006103516, 99.0400009155273, 99.4000015258789, 
99.8300018310547, 98.8000030517578, 97.4800033569336, 97.8499984741211, 
97.5899963378906, 96.0100021362305, 97.3099975585938, 96.8399963378906, 
97.7399978637695, 97.4899978637695, 96.9599990844727, 98.0199966430664, 
97.3099975585938, 97.879997253418, 99.4100036621094, 99.6800003051758, 
99.7900009155273, 98.2799987792969, 96.4100036621094, 95.6699981689453, 
95.4300003051758, 97.620002746582, 97.9100036621094, 98.1999969482422, 
97.5400009155273, 97.620002746582, 96.1900024414062, 96.879997253418, 
96.9899978637695, 96.0400009155273, 95.3499984741211, 95.4700012207031, 
96.5199966430664, 96.4199981689453, 95.9499969482422, 97, 96.4800033569336, 
94.8899993896484, 69.9499969482422, 68.9100036621094, 69.9800033569336, 
71.2200012207031, 72.0500030517578, 70.379997253418, 72.9899978637695, 
72.8600006103516, 73.0199966430664, 74.1399993896484, 72.9199981689453, 
73.3199996948242, 72.6100006103516, 73.4199981689453, 73.2300033569336, 
73.5100021362305, 73.1999969482422, 73.4300003051758, 75.1100006103516, 
75.5599975585938, 75.75, 75.5400009155273, 74.4400024414062, 
74.8499984741211, 75.3199996948242, 76.7600021362305, 76.4199981689453, 
76.3099975585938, 77.7699966430664, 76.9300003051758, 76.9599990844727, 
78.0299987792969, 76.7799987792969, 77.0800018310547, 76.4199981689453, 
76.9599990844727, 79.0500030517578, 78.2900009155273, 79.2300033569336, 
79.6399993896484, 78.620002746582, 79.1699981689453, 79.9599990844727, 
80.4100036621094, 79.370002746582, 80.0299987792969, 79.1500015258789, 
77.3300018310547, 77.2200012207031, 78.5500030517578), begin_date = structure(c(16860, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, 16856, 16856, 16856, 16856, 16856, 16856, 16856, 16856, 16856, 
16856, 16856, 16856, 16856, 16856, 16856, 16856, 16856, 16856, 
16856, 16856, 16856, 16856, 16856, 16856, 16856, 16856, 16856, 
16856, 16856, 16856, 16856, 16856, 16856, 16856, 16856, 16856, 
16856, 16856, 16856, 16856, 16856, 16856, 16856, 16856, 16856, 
16856, 16856, 16856, 16856, 16856, 16860, 16860, 16860, 16860, 
16860, 16860, 16860, 16860, 16860, 16860, 16860, 16860, 16860, 
16860, 16860, 16860, 16860, 16860, 16860, 16860, 16860, 16860, 
16860, 16860, 16860, 16860, 16860, 16860, 16860, 16860, 16860, 
16860, 16860, 16860, 16860, 16860, 16860, 16860, 16860, 16860, 
16860, 16860, 16860, 16860, 16860, 16860, 16860, 16860, 16860, 
16860, 16857, 16857, 16857, 16857, 16857, 16857, 16857, 16857, 
16857, 16857, 16857, 16857, 16857, 16857, 16857, 16857, 16857, 
16857, 16857, 16857, 16857, 16857, 16857, 16857, 16857, 16857, 
16857, 16857, 16857, 16857, 16857, 16857, 16857, 16857, 16857, 
16857, 16857, 16857, 16857, 16857, 16857, 16857, 16857, 16857, 
16857, 16857, 16857, 16857, 16857, 16857, 17128, 17128, 17128, 
17128, 17128, 17128, 17128, 17128, 17128, 17128, 17128, 17128, 
17128, 17128, 17128, 17128, 17128, 17128, 17128, 17128, 17128, 
17128, 17128, 17128, 17128, 17128, 17128, 17128, 17128, 17128, 
17128, 17128, 17128, 17128, 17128, 17128, 17128, 17128, 17128, 
17128, 17128, 17128, 17128, 17128, 17128, 17128, 17128, 17128, 
17128, 17128, 16850, 16850, 16850, 16850, 16850, 16850, 16850, 
16850, 16850, 16850, 16850, 16850, 16850, 16850, 16850, 16850, 
16850, 16850, 16850, 16850, 16850, 16850, 16850, 16850, 16850, 
16850, 16850, 16850, 16850, 16850, 16850, 16850, 16850, 16850, 
16850, 16850, 16850, 16850, 16850, 16850, 16850, 16850, 16850, 
16850, 16850, 16850, 16850, 16850, 16850, 16850), class = "Date")), row.names = c(NA, 
-300L), class = c("grouped_dt", "tbl_dt", "tbl", "tbl_dt", "tbl", 
"data.table", "data.frame"), .internal.selfref = <pointer: 0x0000000002511ef0>, vars = list(
    ID))

我希望每个记录的索引都应该正确分配,但是索引不匹配。

0 个答案:

没有答案