dataTables基础函数变量
DataTable下有四個命名空間(namespace),分別是defaults,ext,models,oApi。
? ? ? ? Defaults:主要是用于初始化表格的一些選項。
? ? ? ? Ext:拓展項,提供額外的表格選項
? ? ? ? Models:類模型容器,這些模型定義用于保存表的活動狀態和信任的對象
? ? ? ? oApi: 一些其他人開發的額外函數,引用插件開發人員使用的內部函數。
? ? ? ? 1個靜態變量 version,3個靜態方法:fnIsDataTable,fnTables,fnVersionCheck。
? ? ? ? ? ?22個方法:
| $(sSelector,?oOpts)?→ {object} | 對table的TR elemente執行jQuery選擇器操作 |
| _(sSelector,?oOpts)?→ {array} | 幾乎與$完全相同 |
| fnAddData(mData,?bRedraw)?→ {array}???? bRedraw是個bool值 | 向表中添加單個新行或多個行數據 |
| fnAdjustColumnSizing(bRedraw) | 這個函數使DataTabales重新計算列大小 |
| fnClearTable(bRedraw) | 快速簡單的清空table |
| fnClose(nTr)?→ {int} | 與“打開”opening"完全相反。這個函數將關閉當前“打開”的任何rovs。 |
| fnDeleteRow(mTarget,?fnCallBack,?bRedraw)?→ {array} | 刪除表中一行 |
| fnDestroy(bRemove) | 完全從DOM中刪除表。 |
| fnDraw(bComplete) | 重繪table |
| fnFilter(sInput,?iColumn,?bRegex,?bSmart,?bShowGlobal,?bCaseInsensitive) | 根據數據過濾 |
| fnGetData(mRow,?iCol)?→ {array|object|string} | 根據提供的參數獲取整個表、單個行或單元格的數據。 |
| fnGetNodes(iRow)?→ {array|node} | 獲取表主體中使用的TR節點的數組。 |
| 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(靜態選項),主要用于初始化 ? ? ?的,給幾個重要的看一下。??
| 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(就是給一些初始化數據) |
| 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(靜態選項),選幾個重要的看一下:
| 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 | 這三個都差不多,看變量名就應該知道它們的意思了。 |
| 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 | 和上面一個差不多,我覺得都是非常重要的函數,如果我要在表格中插入一些標簽的,比如input,a,button等,就會用到,而且挺方便的。 |
| sClass?:string,sName?:string,sTitle?:string,sWidth?:string | 基礎的東西,sClass為每個td設置一個class,sName:只能在dataTable服務端使用,sTitle就是表格header,swidth:調節每個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)是為了方便進行二次開發用的,有85個static methods,涵蓋了defaults命名空間里所有的函數。
? ? ? ? ? ? ext命名空間由models命名空間下的ext繼承了,所以所有內容都在models/ext下。
? ? ? ? ? ? 看亂了吧,說實話我也亂了,然后我就總結了一些,畫了一個思維導圖
? ? ?
原創鏈接:?http://www.cnblogs.com/tonylp
轉載于:https://www.cnblogs.com/baojiao/p/9282906.html
總結
以上是生活随笔為你收集整理的dataTables基础函数变量的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Vmware安装与使用
- 下一篇: 海底2万里中第一个登上潜艇的土著人的名字