[SOLVED] Adding Checkbox column in GridPanel via Ext Designer
[SOLVED] Adding Checkbox column in GridPanel via Ext Designer
I know this is possible to do using Ext.grid.CheckboxSelectionModel but I could not figure out how to do it using the Ext Designer. A brief explanation and/or example would be greatly appreciated.
There may be a much better way to do this, but here's what I did that worked for me:
In Ext Designer I created a grid with a first column that I let default to what you get when you add a column
I removed the header and made the column width 20
Then after Exporting my design, I added the following lines of code to this js file that contains the initialization code for the component:
Code:
// My grid was within a viewport component, the grid had an autoref value of 'docGrid'
MyViewport = Ext.extend(MyViewportUi, {
initComponent: function() {
MyViewport.superclass.initComponent.call(this);
// Create a new checkbox column
var cm = new Ext.grid.CheckboxSelectionModel({
// Put additional config values and listeners here
});
// Replace the grid selection model
this.docGrid.selModel = cm;
// Replace the current first column in the grid with the checkbox column
this.docGrid.colModel.config[0] = cm;
}
});
I hope this helps, and if there's a better way to do this I'd be pleased to know.
Thank you both, that works beautifully! Clyde, you should be writing help manuals - that was exceptionally well explained down to the autoRef id which as a novice I did not know about.
Technical writing improves when your other job, like mine, is writing novels--psychological thrillers set along the Inside Passage! "Red Herring," "Precious Cargo," "Whiskey Gulf" the latest in the series.
Using this exemple works ok. But, if I select all rows and after select just one. the top checkbox keep checked as such as selection model were all selected. How do I fix this? Thanks
Wemerson Januario
Skype: wemerson.januario
Email: wemerson.januario@gmail.com
Fone: 62 84101145 - Goiânia-GO- Brazil Consulting and Training Ext JS
Projects: (Nubes ERP)