• 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();

    一定要明白靠自己
  • 相关阅读:
    桶排序
    Ultra-QuickSort
    Merge Sort
    Max Sum
    快排
    Oil Deposits
    1009: josephus问题
    A+B Again(在某个数中找大于m的最小约数)
    luogu4181 [USACO18JAN]Rental Service (贪心)
    luogu4185 [USACO18JAN]MooTube (并查集)
  • 原文地址:https://www.cnblogs.com/zjpzjp/p/6387532.html
Copyright © 2020-2023  润新知