PDA

View Full Version : ExtJS Autogenerate columns



Pravin.Pawar
5 Sep 2012, 12:02 AM
Hi,

I'm new to ExtJS and NOT sure if we can auto generate columns in ExtJS 4.1 grid.Panel.

Please let me know if there is any way through which we can auto generate columns and load data in grid without using Model.

scottmartin
5 Sep 2012, 12:48 PM
Have a look at:
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.proxy.Proxy-event-metachange
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.reader.Reader-property-metaData

Scott.

Pravin.Pawar
5 Sep 2012, 7:34 PM
Thanks Scott. I'm using diffrent approach for the implementation.

I have used menu control which has various filter options. Based on menu selection; I'm giving AJAX call to filter data and rebinding the grid (...store reload)

Menu control has option to set number of columns needs to display in grid.Panel. I tried to hide columns of grid.Panel somehow there is no luck. We have property hidden: true/ false while creating grid.Panel and next time we are just changing url of store to load data and reload store object which takes care of rebinding grid with new data.

In my case I have to display list of the months like 'January', 'February','March', ... etc and user has option to select how much months data he want to see so the list of the months are required columns in grid.Panel.

Could you please let me know how should I show/ hide grid.Panels columns whenver use change number of required columns from Menu control?

Pravin.Pawar
5 Sep 2012, 9:08 PM
I'm calling following method to rebind grid from menu click handler-

function filterGrid(monthCnt) {
//Load data based on fiter criteria
var Url = "AJAXPages/AjaxPerson.aspx?monthCnt=" + monthCnt;
store.proxy.url = Url;
store.load();
}

menu = Ext.create('Ext.menu.Menu', {
width: 100,
margin: '0 0 10 0',
floating: false,
items: [{
text: 'Month Count',
handler: function (menu, ctl) {
debugger
//Ext.getCmp("gridid").columns[1].hidden = true;
filterGrid(6);
}
}