我有一个数据表,其中使用行分组和来自 gyrocode 的复选框插件.对于任何选定的行,我希望以这种格式返回以下数据:
SFA Id : 目标 ID : SC : 目标 ID
我能够正确返回数据,我什至可以在带有复选框的列中获得额外的间距。
在我的数据函数中,以下返回正确的间距:
// This one works
var myData1 = row[1] + ":" + row[4];
return myData1;
当我添加我希望检索的其他列时,会像这样添加额外的间距:
// The string below will NOT render spacing correctly
var myData2 = row[1] + ":" + row[4] + ":" + row[3] + ":" + row[6];
return myData2;
这是我的 jfiddle与完整的代码。当我想返回 myData2
中的数据时,如何在 myData1
中实现间距?
最佳答案
看起来 DataTables 正在根据您返回的数据长度设置列的大小。试试这个,看看它是否有效。
data: function(row, type, val, meta) {
// we don't care what we display because it's replaced by a checkbox
// so return something small
if (type === 'display') {
return '';
}
// This one works
var myData1 = row[1] + ":" + row[4];
// The string below will NOT render spacing correctly
var myData2 = row[1] + ":" + row[4] + ":" + row[3] + ":" + row[6];
// The string below will NOT render spacing correctly
var myData3 = row[1] + ":" + row[4] + ":" + row[6];
return myData2;
},
关于javascript - 定义数据复选框数据表时列间距不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42818360/