通过使用jquery的datatable插件,我试图收集具有唯一and的行。我使用了.unique,能够在控制台日志中看到数据,如何替换页面上的表。jquery
testdata = [{
"gID": 2,
"name": "An ice sculpture",
"price": 12.50,
"cId": 909,
"tags": ["cold", "ice"],
"dimensions": {
"length": 7.0,
"width": 12.0,
"height": 9.5
}
},
{
"gID": 2,
"name": "An ice sculpture 2-1",
"price": 12.50,
"cId": 909,
"tags": ["cold", "ice"],
"dimensions": {
"length": 7.0,
"width": 12.0,
"height": 9.5
}
}, {
"gID": 2,
"name": "An ice sculpture2 -2",
"price": 12.50,
"cId": 909,
"tags": ["cold", "ice"],
"dimensions": {
"length": 7.0,
"width": 12.0,
"height": 9.5
}
}, {
"gID": 2,
"name": "An ice sculpture2-3",
"price": 12.50,
"cId": 909,
"tags": ["cold", "ice"],
"dimensions": {
"length": 7.0,
"width": 12.0,
"height": 9.5
}
}, {
"gID": 2,
"name": "An ice sculpture",
"price": 12.50,
"cId": 909,
"tags": ["cold", "ice"],
"dimensions": {
"length": 7.0,
"width": 12.0,
"height": 9.5
}
}, {
"gID": 2,
"name": "An ice sculpture",
"price": 12.50,
"cId": 909,
"tags": ["cold", "ice"],
"dimensions": {
"length": 7.0,
"width": 12.0,
"height": 9.5
}
}, {
"gID": 3,
"name": "An ice sculpture 3",
"price": 12.50,
"cId": 309,
"tags": ["cold", "ice"],
"dimensions": {
"length": 7.0,
"width": 12.0,
"height": 9.5
}
}, {
"gID": 4,
"name": "An ice sculpture - 4",
"price": 12.50,
"cId": 989,
"tags": ["cold", "ice"],
"dimensions": {
"length": 7.0,
"width": 12.0,
"height": 9.5
}
}, {
"gID": 5,
"name": "An ice sculpture - 5",
"price": 12.50,
"cId": 919,
"tags": ["cold", "ice"],
"dimensions": {
"length": 7.0,
"width": 12.0,
"height": 9.5
}
}
];
var table = $('#test').DataTable({
"aaData": testdata,
"aoColumns": [{
"mDataProp": "gID"
}, {
"mDataProp": "name"
}],
"bPaginate": true,
"bFilter": true,
"bSort":true,
});
console.log(table.column(0).data().unique());<table id="test"></table>当前结果显示条目搜索:
显示9个条目中的1个到9个( Previous1Next )
预期结果:显示条目搜索:
显示9个条目中的1个到9个( Previous1Next )
发布于 2017-08-16 17:38:01
我觉得这不符合逻辑
预期结果:显示条目搜索: 2冰雕3冰雕3 4冰雕4 5冰雕-5显示9项作品中的1至9项Previous1Next
必须删除重复项,结果将是
2冰雕3冰雕3 4冰雕4 5冰雕5展示4项作品中的1至4项Previous1Next
https://stackoverflow.com/questions/45719615
复制相似问题