I have a dojo(v1.6) data grid which have checkbox to select rows as left most column. I need to have header column of these checkbox as delete button instead of Select All checkbox. On clicking the delete button all selected rows gets deleted.
Please find the Data grid Demo.
I don’t know how to bring the header column of checkbox as button. Please help me to customize the widget. Here is grid js code
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>
You can implement your own CheckBoxSelector from the existing one. I discovered the methods by looking at the
_Selector.js
source. The interesting methods to override weregenerateHtml
anddoclick
.See updated fiddle.
And
To delete the rows
You can parse the grid after startup to create the dijit widgets.