Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery datatables空单元格的默认呈现函数_Jquery_Datatables - Fatal编程技术网

Jquery datatables空单元格的默认呈现函数

Jquery datatables空单元格的默认呈现函数,jquery,datatables,Jquery,Datatables,我想为所有数据表中的所有空单元格定义默认值,但我不想对每一列这样做: $('#example').dataTable( { "ajaxSource": "sources/deep.txt", "columns": [ { "data": "engine" "render": function (data, type, row) { if(row.platform == null) { return "-";

我想为所有数据表中的所有空单元格定义默认值,但我不想对每一列这样做:

$('#example').dataTable( {
  "ajaxSource": "sources/deep.txt",
  "columns": [
    { "data": "engine"
      "render": function (data, type, row) {
          if(row.platform == null) {
            return "-";
          } else {
            return row.platform.display;
          }                 
      },
    },        
    { "data": "browser",
      "render": function (data, type, row) {
          if(row.platform == null) {
            return "-";
          } else {
            return row.platform.display;
          }                 
      },
    },
    {
      "data": "platform",
      "render": function (data, type, row) {
          if(row.platform == null) {
            return "-";
          } else {
            return row.platform.display;
          }                 
      },
    }
  ]
} );
是否有机会在datatable defaults中定义这一点?我该怎么做?或者有更好的地方为空单元格定义此渲染默认操作

/* default values for tables */
$.extend(true, $.fn.dataTable.defaults, {
    dom: "<'table_scroll_container't>" + "<'dt-row dt-bottom-row'<'col-md-4 m-b-10 h30 no-margin-md text-center text-md-left'B i><'col-md-8 m-b-10 h30 no-margin-md text-center text-md-right'l<'clearfix visible-xs-block visible-sm-block'>p>>",
    buttons: [],
    stateSave: true,
    stateDuration: -1,
    iDisplayLength: 50,
    autoWidth: false,
    processing: true,
    language: {
        "processing": "Processing...",
        "info": "Showing _TOTAL_ entries",
        "infoEmpty": "No records available",
        "infoFiltered": "filtered from _MAX_"
    }
});
/*表的默认值*/
$.extend(true,$.fn.dataTable.defaults{
dom:“+”,
按钮:[],
stateSave:没错,
州时:-1,
i显示长度:50,
自动宽度:false,
处理:对,
语言:{
“处理”:“处理…”,
“信息”:“显示总条目”,
“infoEmpty”:“没有可用记录”,
“信息过滤”:“从最大值过滤”
}
});
欢迎使用所有其他提示:)

用于设置列的默认内容

还可以使用它为所有表设置默认值。例如:

$.extend(true, $.fn.dataTable.defaults, {
   columnDefs: [
      {
         targets: '_all',
         defaultContent: '-'
      }
   ]
});
有关代码和演示,请参见。

您可以在这里找到它: