日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

dataTables基础函数变量

發(fā)布時間:2025/5/22 编程问答 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 dataTables基础函数变量 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

DataTable下有四個命名空間(namespace),分別是defaults,ext,models,oApi。

? ? ? ? Defaults:主要是用于初始化表格的一些選項。

? ? ? ? Ext:拓展項,提供額外的表格選項

? ? ? ? Models:類模型容器,這些模型定義用于保存表的活動狀態(tài)和信任的對象

? ? ? ? oApi: 一些其他人開發(fā)的額外函數(shù),引用插件開發(fā)人員使用的內(nèi)部函數(shù)。

? ? ? ? 1個靜態(tài)變量 version,3個靜態(tài)方法:fnIsDataTable,fnTables,fnVersionCheck。

? ? ? ? ? ?22個方法:

$(sSelector,?oOpts)?→ {object}

對table的TR elemente執(zhí)行jQuery選擇器操作

_(sSelector,?oOpts)?→ {array}

幾乎與$完全相同

fnAddData(mData,?bRedraw)?→ {array}???? bRedraw是個bool值

向表中添加單個新行或多個行數(shù)據(jù)

fnAdjustColumnSizing(bRedraw)

這個函數(shù)使DataTabales重新計算列大小

fnClearTable(bRedraw)

快速簡單的清空table

fnClose(nTr)?→ {int}

與“打開”opening"完全相反。這個函數(shù)將關(guān)閉當(dāng)前“打開”的任何rovs。

fnDeleteRow(mTarget,?fnCallBack,?bRedraw)?→ {array}

刪除表中一行

fnDestroy(bRemove)

完全從DOM中刪除表。

fnDraw(bComplete)

重繪table

fnFilter(sInput,?iColumn,?bRegex,?bSmart,?bShowGlobal,?bCaseInsensitive)

根據(jù)數(shù)據(jù)過濾

fnGetData(mRow,?iCol)?→ {array|object|string}

根據(jù)提供的參數(shù)獲取整個表、單個行或單元格的數(shù)據(jù)。

fnGetNodes(iRow)?→ {array|node}

獲取表主體中使用的TR節(jié)點(diǎn)的數(shù)組。

fnGetPosition(nNode)?→ {int}

Get the array indexes of a particular cell from it's DOM element and column index including hidden columns

fnIsOpen(nTr)?→ {boolean}

Check to see if a row is 'open' or not.

fnOpen(nTr, mHtml, sClass)?→ {node}

This function will place a new row directly after a row which is currently on display on the page, with the HTML contents that is passed into the function.

fnPageChange(mAction,?bRedraw)

mAction?? :string | int?????????????????????

Paging action to take: "first", "previous", "next" or "last" or page number to jump to (integer), note that page 0 is the first page.

Change the pagination - provides the internal logic for pagination in a simple API function

fnSetColumnVis(iCol, bShow,?bRedraw)

Show a particular column

fnSettings()?→ {object}

Get the settings for a particular table for external manipulation

fnSort(iCol)

Sort the table by a particular column

fnSortListener(nNode, iColumn,?fnCallback)

Attach a sort listener to an element for a given column

fnUpdate(mData, mRow,?iColumn,?bRedraw,?bAction)?→ {int}

Update a table cell or row - this method will accept either a single value to update the cell with, an array of values with one element for each column or an object in the same format as the original data source.

fnVersionCheck(sVersion)?→ {boolean}

Provide a common method for plug-ins to check the version of DataTables being used, in order to ensure compatibility.

? ? ? ? ? ? ? ? ? ? ? ? ? ?11個事件:

destroy

Destroy event, fired when the DataTable is destroyed by calling fnDestroy or passing the bDestroy:true parameter in the initialisation object.

draw

Draw event, fired whenever the table is redrawn on the page, at the same point as fnDrawCallback

filter

Filter event, fired when the filtering applied to the table (using the build in global global filter, or column filters) is altered.

init

DataTables initialisation complete event, fired when the table is fully drawn, including Ajax data loaded, if Ajax data is required.

page

Page change event, fired when the paging of the table is altered.

processing

Processing event, fired when DataTables is doing some kind of processing (be it, sort, filter or anything else).

sort

Sort event, fired when the sorting applied to the table is altered

stateLoaded

State loaded event, fired when state has been loaded from stored data and the settings object has been modified by the loaded data.

stateLoadParams

State load event, fired when the table is loading state from the stored data, but prior to the settings object being modified by the saved state - allowing modification of the saved state is required or loading of state for a plug-in

stateSaveParams

State save event, fired when the table has changed state a new state save is required.

xhr

Ajax (XHR) event, fired whenever an Ajax request is completed from a request to made to the server for new data

? ? ? ? ? ? ? 接下來在defaults命名空間下包含三個命名空間columns,oLanguage,oSearch,以及58個static properties(靜態(tài)選項),主要用于初始化 ? ? ?的,給幾個重要的看一下。??

aaData?:array

An array of data to use for the table, passed in at initialisation which will be used in preference to any data which is already in the DOM(就是給一些初始化數(shù)據(jù))

aaSorting?:array

You can define which column(s) the sort is performed upon, and the sorting direction, with this variable(初始化時選擇排序的對象,如何排序,例如"aaSorting": [[2,'asc'], [3,'desc']])

aLengthMenu?:array

This parameter allows you to readily specify the entries in the length drop down menu that DataTables shows when pagination is enabled.(就是顯示每頁多少項,例如"aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]])

bJQueryUI?:boolean

Enable jQuery UI ThemeRoller support(但是需要加一些文件,目前正在研究中)

bStateSave?:boolean

Enable or disable state saving. When enabled a cookie will be used to save table display information such as pagination information, display length, filtering and sorting.(這個功能挺有用的)

fnDrawCallback?:function

This function is called on every 'draw' event, and allows you to dynamically modify any aspect you want about the created DOM

fnHeaderCallback?:function

This function is called on every 'draw' event, and allows you to dynamically modify the header row.

fnRowCallback?:function

This function allows you to 'post process' each row after it have been generated for each table draw, but before it is rendered on screen.

? ? ? ? ? ? ? ? ? ? ? ? ? ? ?在defaults命名空間下的columns命名空間下又有21個static properties(靜態(tài)選項),選幾個重要的看一下:

aDataSort?:array

Allows a column's sorting to take multiple columns into account when doing a sort.(多項配合排序時有用)

asSorting?:array

You can control the default sorting direction, and even alter the behaviour of the sort handler

bSearchable?:boolean,bSortable?:boolean,

bVisible?:boolean

這三個都差不多,看變量名就應(yīng)該知道它們的意思了。

mData?:string|int|function|null

This property can be used to read data from any JSON data source property, including deeply nested objects / properties.

mRender?:string|int|function|null

和上面一個差不多,我覺得都是非常重要的函數(shù),如果我要在表格中插入一些標(biāo)簽的,比如input,a,button等,就會用到,而且挺方便的。

sClass?:string,sName?:string,sTitle?:string,sWidth?:string

基礎(chǔ)的東西,sClass為每個td設(shè)置一個class,sName:只能在dataTable服務(wù)端使用,sTitle就是表格header,swidth:調(diào)節(jié)每個td寬度

? ? ? ? ? ? ? 在defaults命名空間下的oLanguage,oSearch命名空間下的變量,命名空間就不說了。

? ? ? ? ? ? ? 在models命名空間下又有5個namespace,分別是ext,oColumn,oRow,oSearch,oSettings。如果有人也在看datatable的doc的話, ? ? ? ? ? ? ? ? 我非常希望有人能具體的跟我說說這個models命名空間有什么作用,我只是有一個模糊的概念。

? ? ? ? ? ? 在oApi命名空間下(Reference to internal functions for use by plug-in developers)是為了方便進(jìn)行二次開發(fā)用的,有85個static methods,涵蓋了defaults命名空間里所有的函數(shù)。

? ? ? ? ? ? ext命名空間由models命名空間下的ext繼承了,所以所有內(nèi)容都在models/ext下。

? ? ? ? ? ? 看亂了吧,說實話我也亂了,然后我就總結(jié)了一些,畫了一個思維導(dǎo)圖

? ? ?

原創(chuàng)鏈接:?http://www.cnblogs.com/tonylp

轉(zhuǎn)載于:https://www.cnblogs.com/baojiao/p/9282906.html

總結(jié)

以上是生活随笔為你收集整理的dataTables基础函数变量的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。