EXTJS gridpanel 动态设置表头,用reconfigure方法

var col = "([{ text :'Company', flex : 1, sortable : false, dataIndex:'company'},{ text:'Stock Price', columns:[{ text :'Price', width : 75, sortable : true, dataIndex:'price'},{ text :'Change', width : 75, sortable : true, dataIndex:'change'},{ text :'% Change', width : 75, sortable : true, dataIndex:'pctChange'}]},{ text :'Last Updated', width : 85, sortable : true, dataIndex:'lastChange'}])";
        var cols = eval(col);
        // Ext.findCmp('testgrid', this).columns.add(cols);
        //var grid = Ext.getCmp('testgrid'); //Ext.findCmp('testgrid', this).columns;
 

         Ext.findCmp('testgrid', this).reconfigure(null, cols);

       //findCmp是自定义根据类id查找控件id的方法

 

以下是EXTJS api说明

reconfigure( [Ext.data.Store store], [Object[] columns] )

Reconfigures the table with a new store/columns. Either the store or the columns can be ommitted if you don't wish to change them.

Parameters

  • store : Ext.data.Store (optional)

    The new store.

  • columns : Object[] (optional)

    An array of column configs

posted on 2013-04-02 16:31  白沙河  阅读(1239)  评论(0编辑  收藏  举报