zoukankan      html  css  js  c++  java
  • datatables的相关问题 和总结

    获取某一列的全部数据

    var api=this.api();
    areas=api.column(0).data();
    pos=api.column(1).data();

    有时候 $('#example').dataTable  小写时也还需要api

    render中的row里面包含的数据是当前行里面所有的数据

    render:function(data,type,row)

    老版本与新版本ajax写法

    ajax:{老版本
      "type":"post",
      "url":url,
      "dataSrc": function (mdata) {
      if(mdata.total){
        sessionStorage.setItem("totalCount",mdata.total);
      }
      return mdata.data;
      }
    },

    ajax: {
          "url":'/api/birds/showClusterBad',
          "traditional": true,
          "data":{
          },
         "dataSrc": function (myData) {
              $("#groScreen").removeClass("disabled");
              if (!myData.success || myData.data == null) {
                   return [];
              } else {
                   var a = [];
                   $.each(myData.data,function(i,v){
                      a.push(myData.data[i]);
                 })
             return a;
            }
        }
    },

    新版

    "ajax": {
          "url": url
          // "type":"post"
          //默认为data,这里定义为demo
          // "dataType": 'jsonp'
          // //默认为data,这里定义为demo
          // "dataSrc": function (mdata) {
          // console.log(mdata);
          // if(mdata.total){
                 // sessionStorage.setItem("totalCount",mdata.total);
     
             // }
            // return mdata.data;
       // }

    },

    option一些参数配置意思

    "displayLength" : 10,//显示条数

    "deferRender": true,//大数据量处理,加快速度;

    "processing": true,
    "destroy": true,
    "retrieve":true,

    language:

    "processing": "正在加载数据...",

    "loadingRecords":" ",如果没有加载到数据的 话   就啥都不提示,默认是:“没有找到数据”

    // "sZeroRecords": "抱歉, 没有找到",

    "infoEmpty": "无记录",

    "decimal":",",
    "thousands":".",

    "paginate": {
      "previous": "上一页",
      "next": "下一页",
      "first": "首页",
      "last": "尾页"
    }

    自定义事件

    // var eventFired = function(type) {
    //
        // if(type=="翻页"){
        // var b=$('body')[0];
        // b.style.backgroundColor="red";
        // console.log('aaaa');
    //
        // console.log('cccc');
     //      }
    // }
          // $('#table_id_example').on('order.dt',
    // function() {
          // eventFired('排序');
    // }).on('search.dt',
    // function() {
           // eventFired('搜索');
    // }).on('page.dt',
    // function() {
          /   / eventFired('翻页');
    // }).dataTable();

    一定要明白靠自己
  • 相关阅读:
    Java入门总结
    Java安装JDK
    ExcelPackage 读取、导出excel
    An error occurred while starting the application.
    EF core2.1+MySQL报错'Void Microsoft.EntityFrameworkCore.Storage.Internal.RelationalParameterBuilder..ctor(Microsoft.EntityFrameworkCore.Storage.IRelationalTypeMapper)
    数据表转换类
    The requested URL /xxxx.html was not found on this server
    .htaccess: Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration
    B2B多商铺初期权限数据库设计
    数据库持久化比较
  • 原文地址:https://www.cnblogs.com/zjpzjp/p/6387532.html
Copyright © 2011-2022 走看看