根据the docs,当columns.render参数是一个函数时,它有四个参数,其中一个是' type':
请求的类型通话数据 - 这将是'过滤','显示', '类型'或者'排序'。
我了解每个选项,但类型为' type'。我无法找到关于类型参数何时或为何类型'键入'。
的任何信息。有谁知道何时或为何输入='键入'?它的用途是什么?
答案 0 :(得分:1)
根据https://datatables.net/manual/data/orthogonal-data,输入="输入"是"类型检测数据" - 用于自动检测column type的数据。
/*{ "name": "Tiger Nixon", "position": "System Architect", "start_date": "1303682400", "office": "Edinburgh" }*/ { data: 'start_date', render: function ( data, type, row ) { // If display or filter data is requested, format the date if ( type === 'display' || type === 'filter' ) { var d = new Date( data * 1000 ); return d.getDate() +'-'+ (d.getMonth()+1) +'-'+ d.getFullYear(); } // Otherwise the data type requested (`type`) is type detection or // sorting data, for which we want to use the integer, so just return // that, unaltered return data; } }
我不认为在type =" type"时提供不同的数据通常很有用。
答案 1 :(得分:0)
我的猜测是文档中的错误/拼写错误。上面的段落定义了三种类型:
函数渲染(数据,类型,行,元)
说明
如果给出了一个函数,它将在DataTables需要时执行 获取列中单元格的数据。注意这个功能 可能会多次调用,因为DataTables会调用它 它需要的不同数据类型 - 排序,过滤和显示。