View Full Version : Render fail in process to restore grid state

17 Aug 2009, 11:01 AM

I have one griview whit some columns, then in the forum I found some code to save and restore the state of the columns int one database. I'am successful return the information about It in the database and send to the grid. But when I iterate in the cm.Config and set the values for each config and call the cm.setConfig(newConfig), the columns is not rendered correctly. see in the picture attached.

var or = Ext.decode(response.responseText); // the state return in the db
if (or.Success) {
var cm = grid.getColumnModel();
var newConfig = cm.config;
ds = grid.getStore()

for (var i = 0; i < or.Result[0].Data.length; i++) {
newConfig[i].dataIndex = or.Result[0].Data[i].dataIndex;
newConfig[i].hidden = or.Result[0].Data[i].hidden;
newConfig[i].width = or.Result[0].Data[i].width;
sort = {
direction : or.Result[0].Data[i].direction,
dataIndex : or.Result[0].Data[i].dataIndex
if (sort) {
ds.sort(sort.dataIndex, sort.direction);
cm.setConfig(newConfig); At this point, the columns are not rendered correctly.
Well, where I'am write someone wrong? It is missing some configuration? :-? Below in the left picture the correctly columns rendered whit default grid columns config, and in the right picture, the worng columns after the call to cm.setConfig(newConfig) to set the stored state columns config.

18 Aug 2009, 9:29 AM