PDA

View Full Version : GridPanel: How do I dynamically creating column



soulgen
11 May 2010, 8:39 PM
Would anyone help me to do dynamically creating column (via data from db) in gridpanel?
or just referencing me to the another threads that posts same problem (and has been solved, ofcourse) ?

thank you!

Fredric Berling
11 May 2010, 10:03 PM
search API for "reconfigure" . This function helps you dynamically change both store and columnModel.

CrazyEnigma
11 May 2010, 10:09 PM
@ Fredric Berling: That solved one of my problems thanks. I have been looking for the answer to that problem. Hmm....

webtime
12 May 2010, 1:43 AM
@Crazy...
Hy, this is my code. I hope that this code can help you!!!!
Bye...


Ext.onReady(function(){


Pgridaction = document.forms[0].gridAction.value;
Paction = document.forms[0].action.value;
Pclassnameltbl = document.forms[0].classNameLTBL.value;
Puserobject = document.forms[0].userObject.value;
Putente = document.forms[0].utente.value;
Pparametergrid = document.forms[0].parameterGrid.value;
Pjspobject = document.forms[0].jspObject.value;
Pvisualkey = document.forms[0].visualKey.value;
Pjsplist = document.forms[0].jspList.value;
Pservletforgrid = document.forms[0].servletForGrid.value;
Pservletexecutefromgrid = document.forms[0].servletExecuteFromGrid.value;
Pbasehref = document.forms[0].baseHref.value;
Ppage = document.forms[0].page.value;
Pcomponent = document.forms[0].component.value;
Pgridtype = document.forms[0].gridType.value;
Pmessagesltbl = document.forms[0].messagesLTBL.value;
Pgridcode = document.forms[0].gridCode.value;
Pgriduser = document.forms[0].gridUser.value;
Pjspwidth = document.forms[0].jspWidth.value;
Pjspheight = document.forms[0].jspHeight.value;
Psessid = document.forms[0].sessid.value;
Pbase = document.forms[0].base.value;
url = Pbase+"servlet/org.ltblfw.web.WebJson";
resultPageSize = 35;

var store = new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({ url: url, method: 'GET' }),
baseParams : {
gridAction: Pgridaction,
action: Paction,
classNameLTBL: Pclassnameltbl,
userObject: Puserobject,
utente: Putente,
parameterGrid: Pparametergrid,
jspObject: Pjspobject,
visualKey: Pvisualkey,
jspList: Pjsplist,
servletForGrid: Pservletforgrid,
servletExecuteFromGrid: Pservletexecutefromgrid,
baseHref: Pbasehref,
page: Ppage,
component: Pcomponent,
gridType: Pgridtype,
messagesLTBL: Pmessagesltbl,
gridCode: Pgridcode,
gridUser: Pgriduser,
jspWidth: Pjspwidth,
jspHeight: Pjspheight,
sessid: Psessid
},
fields:[]
});
store.load({
params: {
start: 0,
limit: 35
}
});
var xgrid = new Ext.grid.GridPanel({
store:store,
columns:[],
height: 500,
loadMask: true,
viewConfig: {
onDataChange: function(){
this.cm.setConfig(this.ds.reader.jsonData.columns);
this.syncFocusEl(0);
}
},
bbar: new Ext.PagingToolbar({
store: store,
pageSize: resultPageSize
}),
////////////////////////
tbar:[{
id:'tbtnAdd',
text:'Add Category',
tooltip:'Add a new category',
iconCls:'add'
},{
id:'tbtnEdit',
text:'Edit Category',
tooltip:'Edit the selected category',
iconCls:'option',
disabled: true
},{
id:'tbtnRemove',
text:'Remove Category',
tooltip:'Remove the selected category',
iconCls:'remove',

disabled: true
}],
///////////////////////////////
renderTo: 'datagrid'
});
store.on('datachanged',
function () {
xgrid.reconfigure(store, xgrid.getColumnModel())
}
)
});