fnadddata 怎么添加multiple c tb1.rows.add 1

扫一扫关注官方微信Using jQuery DataTables plugin, does fnAddData() add rows to the top or bottom of an html table? - Stack Overflow
to customize your list.
Announcing Stack Overflow Documentation
We started with Q&A. Technical documentation is next, and we need your help.
Whether you're a beginner or an experienced developer, you can contribute.
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.
Any ideas ??
16.1k2276231105
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).
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.
74.9k15123166
Browsing through the source of Datatable, as explained by kgiannakaki. The method will append all new data rows to the end of the table as it should.
The reason for the "random" behavior, is as each time a new row is added the method will perform a "redraw" of the entire table unless otherwise specified. When this does so the table is run through multiple features such as filtering/sorting etc etc ... and completely rewritten to the page. Essentially I am going to guess you are adding random bits of data into new rows which may be creating the "random" effect, whenever a new row is added.
You can easily disable table redrawing by adding a second parameter in the fnAddData call which needs to be set to false.
$(this).fnAddData(data, false);
If this issue still persists I would file a bug for this issue, as their is no other reason for this behavior.
To disable sorting, so that a new row will be appended to the bottom of a table, add
"bSort": false
to (the top of) your DataTable initialization.
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
您的访问请求被拒绝 403 Forbidden - ITeye技术社区
您的访问请求被拒绝
亲爱的会员,您的IP地址所在网段被ITeye拒绝服务,这可能是以下两种情况导致:
一、您所在的网段内有网络爬虫大量抓取ITeye网页,为保证其他人流畅的访问ITeye,该网段被ITeye拒绝
二、您通过某个代理服务器访问ITeye网站,该代理服务器被网络爬虫利用,大量抓取ITeye网页
请您点击按钮解除封锁&

我要回帖

更多关于 c tb1.rows.add 1 的文章

 

随机推荐