Mar 28, 2014, 6:01 AM
[CLOSED] Remove Grid Column by column index.
Hello,
I have a java script function which inserts the column and removes the column from the grid. It was working fine in previous version of Ext.Net i.e Ext.Net 2.1 As I have upgraded the version of Ext.Net to 2.5 I have unable to remove the column from grid.
The code to remove column is:
The code to add/insert the column is:
I have a java script function which inserts the column and removes the column from the grid. It was working fine in previous version of Ext.Net i.e Ext.Net 2.1 As I have upgraded the version of Ext.Net to 2.5 I have unable to remove the column from grid.
triggerStore.load({
params: { "tableName": modelName },
scope: this,
callback: function (records, operation, success) {
debugger;
//the operation object contains all of the details of the load operation
if (success) {
first remove the column from the current grid.The code to remove column is:
if (grid.columnManager.columns.length > 2) {
for (var k = 0; k < (grid.columnManager.columns.length) ; k++) {
if (grid.columnManager.columns.length == 2) break;
if (grid.columnManager.columns[k].dataIndex != "") {
//var col = grid.columnManager.columns[k]
//col.removeAll(false);
//problem in ext.net 2.5
grid.removeColumn(k, true);
k = 0;
}
}
}
Now add the new columns in the grid.The code to add/insert the column is:
for (var j = 0; j < triggerStore.model.getFields().length; j++) {
var title = triggerStore.model.getFields()[j].name;
if (title != "id") {
if (title == "IsPrimary") {
var eColumn = Ext.create('Ext.grid.column.CheckColumn', { header: title, dataIndex: title });
grid.insertColumn(j + 1, eColumn, true);
}
else {
var eColumn = Ext.create('Ext.grid.column.Column', { header: title, dataIndex: title });
grid.insertColumn(j + 1, eColumn, true);
}
}
}
This code worked fine in Ext.Net.MVC 2.1 but failed in 2.5. The main problem is though the column is inserted the grid.column is always 0 but updated in grid.columnManager. As I remove the column the from grid the column is null.
Last edited by Daniil; Apr 20, 2014 at 3:39 PM.
Reason: [CLOSED]