PDA

View Full Version : Dynamic set value of a item of a store in a datagrid



webeex
20 Feb 2012, 9:59 PM
Hello,<br><br>I trying to figuring out something that's maybe simple, but didn't find a way to do it.<br><br>I have 3 mysql tables, set in 3 differents Ext.data.model shown in 3 Ext.grid.panel : Business, Contact, Call<br><br>When I click on a row of the Business table, the contact and call grid are updated to show only the data related to the selected business Id.<br><br>I use the Ext.grid.plugin.RowEditing to edit the rows on each table, but I didn't figuring out how to set the idBusiness from the table Contact and Cell using the value of the business id from the selected row of the first table.<br><br>I think there's many possibility to do it, I tried a lot but didn't figuring out to get proper result. (tried to set a "dynamic" default value of the item of the model, tried a loop to "manually" set the value of this field...)<br><br><br>Mysql data are get and set via a php script.<br><br>(Sorry if I'm not clear enough, it's late and english isn't my primary language)

mitchellsimoens
21 Feb 2012, 6:07 AM
So you're not getting how to load the other two grids based on the selection of the first?

webeex
21 Feb 2012, 6:40 AM
No, I'm able to load the values for the other grid, I even set the grids titles with values from the 1st grid.

I just didn't figure out how to set the value (using the value "get" from the 1st grid) of a cell when I add a new row to the 2nd and 3rd grid.

mitchellsimoens
21 Feb 2012, 6:49 AM
When you create the new record, you can pass the data to it there or after the record is created you can use the set method on the record.

webeex
22 Feb 2012, 8:16 AM
ok thank for the hint, I realise I was doing the right thing at the wrong place.

I add the set when i create the new record and it's work.



...
items: [{iconCls: 'add', text: 'Ajouter',
handler: function() {
contactEditing.cancelEdit();
var record = Ext.create('ModelContact');
storeContact.insert(0, record);
contactEditing.startEdit(0, 0);
var record = gridContact.getSelectionModel().selected.items[0]
record.set('idEntreprise', vidEntreprise);
}
},
...