DataTablesDemo

待研究 datatables 的 编辑功能: https://editor.datatables.net/examples/inline-editing/simple.html

http://www.cnblogs.com/zjf1987/p/JQueryDataTablesEditor.html

http://www.cnblogs.com/zjf1987/p/Editor.html

http://www.tuicool.com/articles/n2Efyq

{

        "processing": "玩命加载中...",

        "lengthMenu": "显示 _MENU_ 项结果",

        "zeroRecords": "没有匹配结果",

        "info": "显示第 _START_ 至 _END_ 项结果,共 _TOTAL_ 项",

        "infoEmpty": "显示第 0 至 0 项结果,共 0 项",

        "infoFiltered": "(由 _MAX_ 项结果过滤)",

        "infoPostFix": "",

        "search": "搜索:",

        "url": "",

        "paginate": {

                "first":    "首页",

                "previous": "上页",

                "next":     "下页",

                "last":     "末页"

        }
}

怎么在首列添加checkbox

自定义数据源属性(Custom data source property)

现在的传回格式应该为datapo,可能需要修改

ajax.dataOption ajax.data不定时一讲 增加或修改通过Ajax提交到服务端的请求数据

var table = $("#tableid").DataTable({
    ajax:{
        url:"data.action",
        type:"POST",
        data:{
            beginDate:$("#beginDate").val(),
            endDate:$("#endDate").val()
        }
    },
    columns:[
        {data:"name"},
        {data:"age"}
    ]});

操作从服务器返回的数据,给数据添加链接

$('#example').dataTable( { "ajax": { "url": "data.json", "dataSrc": function ( json ) { for ( var i=0, ien=json.data.length ; i<ien ; i++ ) { json.data[i][0] = '<a href="/message/'+json.data[i][0]+'">View message</a>'; } return json.data; } } } );

http://datatables.club/reference/option/ajax.dataSrc.html

ajax.json() 获取返回的json格式数据

var table = $('#example').DataTable( {
    ajax: "data.json"
} );

table.on( 'xhr', function () {
    var json = table.ajax.json();
    alert( json.data.length +' row(s) were loaded' );
} );
https://datatables.net/reference/api/ajax.json()

获取本地的数据

```$('#example').dataTable( { "ajax": function (data, callback, settings) { callback( JSON.parse( localStorage.getItem('dataTablesData') ) ); } } );

http://datatables.club/reference/option/ajax.html```

更改Ajax的请求方式

```$('#example').dataTable( { "ajax": { "url": "data.json", "type": "POST" } } );

###每30秒重新加载表数据(分页重置)

```var table = $('#example').DataTable( {
    ajax: "data.json"
} );

setInterval( function () {
    table.ajax.reload();
}, 30000 );

每30秒重新加载表数据(分页留存)

```var table = $('#example').DataTable( { ajax: "data.json" } );

```setInterval( function () {
    table.ajax.reload( null, false ); // 刷新表格数据,分页信息不会重置
}, 30000 );

使用回调函数来更新外部元素

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

table.ajax.reload( function ( json ) {
    //这里的json返回的是服务器的数据
    $('#myInput').val( json.lastInput );
} );

http://datatables.club/reference/api/ajax.reload().html

得到当前url

var table = $('#example').DataTable( {
    ajax: 'data.json'
} );

alert( 'Data source: '+table.ajax.url() ); 
// 将打印 'Data source: data.json'

设置新的数据源,并立即加载

var table = $('#example').DataTable( { ajax: "data.json" } ); table.ajax.url( 'newData.json' ).load();

手册: 各种数据如何处理

默认设置(Setting defaults)

// 默认禁用搜索和排序
$.extend( $.fn.dataTable.defaults, {
    searching: false,
    ordering:  false
} );

// 这样初始化,排序将会打开
// 搜索功能仍然是关闭
$('#example').DataTable( {
    ordering: true
} );

对于全站相同的选项可以设置为模式设置.

样式定制

columnDefs

$('#example').dataTable( {
  "columnDefs": [ {
    "targets": 0,
    "data": function ( row, type, val, meta ) {
      if (type === 'set') {
        row.price = val;
        // Store the computed display and filter values for efficiency
        row.price_display = val=="" ? "" : "$"+numberFormat(val);
        row.price_filter  = val=="" ? "" : "$"+numberFormat(val)+" "+val;
        return;
      }
      else if (type === 'display') {
        return row.price_display;
      }
      else if (type === 'filter') {
        return row.price_filter;
      }
      // 'sort', 'type' and undefined all just use the integer
      return row.price;
    }
  } ]
} );

{
  "total": 45,
  "rows": [
    {
      "createTime": "2016-05-12 15:56:29.0",
      "themeId": 1463039796849,
      "firstResult": 0,
      "themeRefStyle": 1,
      "seoName": null,
      "ids": null,
      "seoDesc": null,
      "sortId": 0,
      "shareTitle": "",
      "pageSize": null,
      "maxResult": null,
      "shareContent": "",
      "id": 125,
      "page": null,
      "themeName": "123123123123",
      "sortType": 0,
      "seoKeyWord": null,
      "webMenuStyle": 0,
      "isValid": 0,
      "themeIntro": "",
      "pageMenuStyle": 0,
      "themeType": 0
    },
    {
      "createTime": "2016-05-12 13:44:14.0",
      "themeId": 1463031861754,
      "firstResult": 0,
      "themeRefStyle": 0,
      "seoName": null,
      "ids": null,
      "seoDesc": null,
      "sortId": 0,
      "shareTitle": "",
      "pageSize": null,
      "maxResult": null,
      "shareContent": "",
      "id": 124,
      "page": null,
      "themeName": "11111",
      "sortType": 0,
      "seoKeyWord": null,
      "webMenuStyle": 0,
      "isValid": 0,
      "themeIntro": "",
      "pageMenuStyle": 0,
      "themeType": 0
    },
    {
      "createTime": "2016-05-04 17:30:40.0",
      "themeId": 1462354251401,
      "firstResult": 0,
      "themeRefStyle": 1,
      "seoName": "Tina-2个-侧边-切换-样式关键词",
      "ids": null,
      "seoDesc": "Tina-2个-侧边-切换-样式2描述",
      "sortId": 0,
      "shareTitle": "Tina-2个-侧边-切换-样式2",
      "pageSize": null,
      "maxResult": null,
      "shareContent": "Tina-2个-侧边-切换-样式2",
      "id": 96,
      "page": null,
      "themeName": "Tina-2个-侧边-切换-样式2",
      "sortType": 0,
      "seoKeyWord": "Tina-2个-侧边-切换-样式关键词",
      "webMenuStyle": 0,
      "isValid": 1,


paramMap={page=1, pageSize=30, firstResult=0, maxResult=30}

results matching ""

    No results matching ""