【发布时间】:2014-01-04 08:35:28
【问题描述】:
我有一个 dojo(v1.6) 数据网格,它有一个复选框来选择行作为最左边的列。我需要将这些复选框的标题列作为删除按钮而不是全选复选框。单击删除按钮后,所有选定的行都会被删除。
请查找Data grid Demo。
我不知道如何将复选框的标题列作为按钮。请帮我自定义小部件。 这是网格js代码
dojo.ready(function(){
/*set up data store*/
var data = {
identifier: 'id',
items: []
};
var data_list = [
{ col1: "normal", col2: false, col3: 'But are not followed by two hexadecimal', col4: 29.91},
{ col1: "important", col2: false, col3: 'Because a % sign always indicates', col4: 9.33},
{ col1: "important", col2: false, col3: 'Signs can be selectively', col4: 19.34}
];
var rows = 10;
for(var i=0, l=data_list.length; i<rows; i++){
data.items.push(dojo.mixin({ id: i+1 }, data_list[i%l]));
}
var store = new dojo.data.ItemFileWriteStore({data: data});
/*set up layout*/
var layout = [
{ type: "dojox.grid._CheckBoxSelector" },
[
{'name': 'Column 1', 'field': 'id', 'width': '20%'},
{'name': 'Column 2', 'field': 'col2', 'width': '20%'},
{'name': 'Column 3', 'field': 'col3', 'width': '25%'},
{'name': 'Column 4', 'field': 'col4', 'width': '20%'}
]
];
/*create a new grid:*/
var grid = new dojox.grid.DataGrid({
id: 'grid',
store: store,
structure: layout,
cellOverClass: 'cellover'
},
document.createElement('div')
);
/*append the new grid to the div*/
dojo.byId("gridDiv").appendChild(grid.domNode);
/*Call startup() to render the grid*/
grid.startup();
});
HTML
<div id="gridDiv"></div>
【问题讨论】:
-
可能不是你想要的,但你可以查看 grids headerMenu 属性。
-
@tik27 在这种情况下,您是否在菜单插件中提到
dojox.grid.EnhancedGrid?我使用的是普通的dojox.grid.dataGrid。能否请您发布网格 headerMenu 属性的参考链接?
标签: javascript grid dojo dojox.grid.datagrid