使用jQuery DataTables插件,fnAddData()是否将行添加到html表的顶部或底部? [英] Using jQuery DataTables plugin, does fnAddData() add rows to the top or bottom of an html table?

查看:1432
本文介绍了使用jQuery DataTables插件,fnAddData()是否将行添加到html表的顶部或底部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经测试了这个,我问的原因是它似乎在为不同的表做不同的事情。

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表的顶部或底部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆