问题描述
我已经测试过了,我问这个问题的原因是它似乎对不同的表做不同的事情.
I have tested this and the reason I asked the question is that it seems to be doing different things for different tables.
我找不到关于这是否可配置的任何文档.我原以为它会将行添加到底部,但我有一些示例,我看到它有时会在顶部甚至中间添加行.看起来很随意.
I couldn't find any documentation on if this is configurable or not. I would have thought it would add the rows to the bottom, but I have a few examples where I see it adding rows at the top or even in the middle sometimes. It seems quite random.
有什么想法吗?
推荐答案
我查看了源代码,fnAddData 调用内部方法 _fnAddData,该方法添加一行,如果成功,则返回其在表中的索引._fnAddData 在底部添加新行(新行的索引等于表中的行数).
I have looked at the source code and fnAddData calls the internal method _fnAddData, which adds one row and if successful, returns its index in the table. _fnAddData adds the new row at the bottom (the index of the new row equals the number of the rows in the table).
然而,fnAddData 有一个可选参数来重新绘制表格,同时考虑到已启用的各种功能.此参数默认为 true,这可能是导致随机"行为的原因.
However, fnAddData has an optional parameter to redraw the table taking into account the various features which are enabled. This parameter defaults to true and this is what probably causes the 'random' behavior.
这篇关于使用 jQuery DataTables 插件,fnAddData() 是否将行添加到 html 表的顶部或底部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!