PDA

View Full Version : autoload editorgridpanel



pegasus
1 Dec 2009, 2:13 PM
I have an editorgridpanel (ColumnModel) where one of the rows is a ComboBox. Based on the value in the Combobox, is it possible to add new rows (fetch data from server) into the grid?

Currently I do it by recreating a panel on the existing panel by adding a 'select' listener to the combobox. But I need to refresh/reload the panle/editorgridpanel to do it the right way.

Any ideas?

husniadil
1 Dec 2009, 2:36 PM
I have an editorgridpanel (ColumnModel) where one of the rows is a ComboBox.Did you mean one of the columns has ComboBox editor? or probably you meant that the first row is ComboBox? or no rows is ComboBox but one random row?


Based on the value in the Combobox, is it possible to add new rows (fetch data from server) into the grid?Add new row means doing insert a record... why do you mean it fetch data from server?



Currently I do it by recreating a panel on the existing panel by adding a 'select' listener to the combobox. But I need to refresh/reload the panle/editorgridpanel to do it the right way. What panel did you mean? The container of your EditorGridPanel?


I'm pretty confused what did u mean... @[email protected]

pegasus
1 Dec 2009, 2:58 PM
Yep, one of the columns is a ComboBox. Since the grid is populated by a simplestore to add new rows the store must fetch the data from the server again.

Here is a brief view of what I have:

function xxx {
$.getJSON (url, function(data) {
gridStore = new Ext.data.SimpleStore({
data: data,
fields: ['name','type','value', 'col_name']
});


var typeCombo = new Ext.form.ComboBox({
..
listeners: {'select': xxx }
});


var grid = new Ext.grid.EditorGridPanel({
..
ds: gridStore,
cm: new Ext.grid.ColumnModel({ ..
editors : {'type': new Ext.grid.GridEditor( typeCombo) }
})
});


var centerTab = new Ext.Panel({
id: tabId,
items: [grid]
});

});
}


The rowdata is dynamically fetched to the store using getJSON. The ColumnModel adds new rows based on this data into the grid. The ComboBox value decides the new rows to be updated. Currently the function xxx is being used to recreate the whole process once the user selects the value. So the panel is recreated with the editorgridpanel inside it.

husniadil
2 Dec 2009, 5:23 AM
did u mean like this (http://mashusni.co.cc/files/extjs-grid/)?

try double click on any rows at the first column...

pegasus
2 Dec 2009, 7:59 AM
Thank you husniadil, for your response. That is exactly what I need to do. I adapted the above example in my code and there's a "missing } after property list" error on the columnmodel, I've double-checked the syntax and there doesn't seem to be anything missing. Does it make a difference if my Combo store and Simplestore is defined outside the ColumnModel & Editorgridpanel?

I have it defined in this order since there are more than one combostores and more than one render functions.


Thank you.

PS: I very much appreciate your quick response.

husniadil
2 Dec 2009, 10:04 AM
I'm glad for your response too.. :)


Does it make a difference if my Combo store and Simplestore is defined outside the ColumnModel & Editorgridpanel?
there's no difference, both are in same result... I just prefer to define my store outside the grid than inside.


If I want to call my store, just call the variable name..

mystore.method();


if you define your store inside the grid, you call it with longer code:

mygrid.getStore().method();

pegasus
3 Dec 2009, 8:55 AM
Thank you. That worked nicely!