Jquery 如何在slickgrid中添加隐藏柱
有可能在网格中有一个隐藏的列吗?所谓隐藏列,我的意思是我想为每一行保存一些数据,但我不希望这些数据显示在网格上。我认为可以通过使用Jquery 如何在slickgrid中添加隐藏柱,jquery,slickgrid,Jquery,Slickgrid,有可能在网格中有一个隐藏的列吗?所谓隐藏列,我的意思是我想为每一行保存一些数据,但我不希望这些数据显示在网格上。我认为可以通过使用网格来实现这一点。setColumns-假设在声明网格时设置了列={id,a,b,c};网格初始化后,可以调用grid.setColumns(newColumns)-其中newColumns是新的列数组,它不包括id-newColumns={a,b,c} 此列仍然可以访问,与之相关的所有数据也应该可用 希望这有帮助 数据和网格中的列之间没有隐含的关系-两者完全独立存在
网格来实现这一点。setColumns
-假设在声明网格时设置了列={id,a,b,c}
;网格初始化后,可以调用grid.setColumns(newColumns)
-其中newColumns
是新的列数组,它不包括id-newColumns={a,b,c}
此列仍然可以访问,与之相关的所有数据也应该可用
希望这有帮助 数据和网格中的列之间没有隐含的关系-两者完全独立存在。因此,数据可以包含比实际绑定到网格列的字段多得多的字段 例如:
var grid;
var columns = [
{id: "title", name: "Title", field: "title"},
{id: "duration", name: "Duration", field: "duration"},
{id: "%", name: "% Complete", field: "percentComplete"},
{id: "effort-driven", name: "Effort Driven", field: "effortDriven"}
];
var options = {
enableCellNavigation: true,
enableColumnReorder: false
};
$(function () {
var data = [];
for (var i = 0; i < 500; i++) {
data[i] = {
title: "Task " + i,
duration: "5 days",
percentComplete: Math.round(Math.random() * 100),
start: "01/01/2009",
finish: "01/05/2009",
effortDriven: (i % 5 == 0)
};
}
grid = new Slick.Grid("#myGrid", data, columns, options);
})
var网格;
变量列=[
{id:“title”,name:“title”,field:“title”},
{id:“duration”,name:“duration”,field:“duration”},
{id:“%”,名称:“%Complete”,字段:“percentComplete”},
{id:“努力驱动”,名称:“努力驱动”,字段:“努力驱动”}
];
变量选项={
enableCellNavigation:true,
enableColumnReorder:false
};
$(函数(){
var数据=[];
对于(变量i=0;i<500;i++){
数据[i]={
标题:“任务”+i,
持续时间:“5天”,
完成百分比:Math.round(Math.random()*100),
开始日期:“01/01/2009”,
完成日期:“01/05/2009”,
轻松驱动:(i%5==0)
};
}
grid=new Slick.grid(“myGrid”,数据、列、选项);
})
这里我的
数据
数组包含开始
和结束
字段,但我选择在创建列
数组时排除这些字段。在网格版本中,您可以执行以下操作
1.在列定义中,包括所有列的
2.现在,重新添加您希望在网格中看到的列id。现在加载页面并查看列选择器菜单。您将很高兴看到所有专栏。一些未经检查
e、 g
我把这个放在哪里?我认为这不是一个好办法。太好了!我想这会打破你的计划。谢谢njr。这是正确的。但是在我的情况下,总共有8列,其中4列显示在网格中。使用复合编辑器时,如果未声明列,如何定义列编辑器?“visible”列属性非常好。下面是复合编辑器和复合编辑器的示例
this.columnDefinitions = [
{ id: 'name', name: 'Name', field: 'name', filterable: true, sortable: true },
{ id: 'duration', name: 'Duration', field: 'duration', filterable: true,sortable: true },
{ id: 'complete', name: '% Complete', field: 'percentComplete', filterable:true,sortable: true }
];
this.gridOptions = {
presets: {
// the column position in the array is very important and represent
// the position that will show in the grid
columns: [
{ columnId: 'duration', width: 88, headerCssClass: 'customHeaderClass' },
{ columnId: 'complete' }
]
// name will be present in the menu but not on the grid