The difference between DataTable () and DataTable () and how to handle it

Source: Internet
Author: User

There are two ways to initialize a jQuery DataTable:

var datatable = $ (' #example '). DataTable ();
And

var DataTable = $ (' #example '). DataTable ();

Both are capable of initializing a DataTable. However, the result of inference datatable==datatable is false.

The reason: The DataTable is an old data table construct that returns a JQuery object. This jquery object is a rich API approach. such as Fnfilter. Fndeleterow and so on.

Such as:

DataTable.fnDeleteRow(0); DataTable.fnAddData([‘E‘, ‘F‘]);

Suppose you need to keep the old code, or for some reason need to use the old DataTable's constructor. However, you still need to use the new Api,jquery object extension (from 1.10.0).

The API () method returns the new API:

DataTable.api().row(0).remove();
Datatable.<span class= "PLN" >api</span><span class= "pun" > (). </span><span class= "PLN" >row</span><span class= "pun" >.</span><span class= "PLN" >add</span><span class= "Pun" > ([</span><span class= "str" > ' E ' </span><span class= "pun" >,</span><span class= "PLN" > </span><span class= "str" > ' F ' </span><span class= "pun";]) .</span>< Span class= "PLN" >draw</span><span class= "pun" > ();</span>




The difference between DataTable () and DataTable () and how to handle it

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.