Reputation: 3811
Hi i'm trying to insert a new row in a grid, but one column of it is in fact a concatenation of two values, I'd like to do something like this :
var scopename = newScopeRef.down('textfield[id=scope_name]').getValue();
var prodname = newScopeRef.down('combobox[id=prd]').getRawValue();
var relname = newScopeRef.down('combobox[id=p_rls]').getRawValue();
var editscopegrid = newScopeRef.down('gridpanel[id=editedscope_grid]'); //my grid
editscopegrid.getView().getStore().removeAll();
editscopegrid.getView().getStore().add({
name_scope : scopename,
prodrel : concat(prodrel + ',' prodname + ' ' + relname)});
editscopegrid.getView().refresh();
As you can see I'd like to concatenante the existing value of the column prodrel
of the grid with the values of the comboboxes prodname
and relname
, separated by a space.
I'm using Extjs 4.x with the MVC architecture, above is the handler of the click event of a button "update" on my panel.
How can I do this please?
Upvotes: 3
Views: 5074
Reputation: 231
If you have an explicit model definition you can add a prodrel
field with a convert
function and do the concatenation there.
Ext.define('MyModel', {
extend : 'Ext.data.Model',
fields : [
'name_scope',
'prodname',
'relname',
{
name : 'prodrel',
convert : function (v, rec) {
return rec.get('prodname') + ' ' + rec.get('relname');
}
}
]
}
Then you can add an instance to your store like so...
editscopegrid.getView().getStore().add({
name_scope : scopename,
prodname : prodname,
relname : relname});
Upvotes: 4