PDA

View Full Version : Populating Editor Grid with Combobox



Ourysso
19 Nov 2010, 4:48 AM
Hi everyone. I need some help.

I have this EditorGrid:




var storeMateriais = new Ext.data.DirectStore({
directFn: Superaconsole.carregaMateriaisRequisicao,
root: 'root',
idProperty: 'Id',
fields: [
{name: 'Id', type: 'string'},
{name: 'Material', type: 'string'},
{name: 'Plano_de_Conta', type: 'string'},
{name: 'Quantidade', type: 'string'},
{name: 'UN', type: 'string'},
{name: 'Gerado', type: 'string'}
],
paramOrder: 'requisicaoid'
});

storeMateriais.load({params: {requisicaoid: codigo}});


var ColumnModel = new Ext.grid.ColumnModel({
columns: [
{header: 'Id', id: "id", dataIndex: 'Id', hidden: true},
{header: "Material", id: "Material", dataIndex: 'Material', editor: editor_combo_material},
{header: "Plano de Conta", id: "Plano_de_Conta", dataIndex: 'Plano_de_Conta', editor: editor_combo_planoconta, width: 150},
{header: "Quantidade", id: "Quantidade", dataIndex: 'Quantidade', editor: editor_quantidade, width: 70, align: 'right'},
{header: "UN", id: "UN", dataIndex: 'UN', width: 30, align: 'center'},
{header: "Gerado", id: "Gerado", dataIndex: 'Gerado', width: 50, align: 'center'}
]});


var grid_materiais = new Ext.grid.EditorGridPanel({
x: 10,
y: 185,
id: 'grid_materiais',
title: '<center>Materiais</center>',
frame: false,
border: true,
columnLines: true,
anchor: '-10px',
enableColumnMove: false,
enableHdMenu: false,
bodyStyle: 'border-color: #B5B8C8; padding: 0px;',
autoExpandColumn: "Material",
height:200,
clickstoEdit: 1,
store: storeMateriais,
cm: ColumnModel,
sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
});


How you can see the column "Material" have a Editor. That editor is this Combobox:



var storeComboMateriais = new Ext.data.DirectStore({
directFn: Superaconsole.carregaComboMateriais,
root: 'root',
idProperty: 'Id',
fields: [
{name: 'Id', type: 'string'},
{name: 'Material', type: 'string'},
{name: 'Plano_de_Conta', type: 'string'},
{name: 'UN', type: 'string'}
]
});

storeComboMateriais.load();

var editor_combo_material = new Ext.form.ComboBox({
id: 'combo_material',
store: storeComboMateriais,
triggerAction: 'all',
mode: 'remote',
selectOnFocus: true,
forceSelection: true,
lazyRender: true,
editable: false,
displayField:'Material',
valueField: 'Material',
loadingText: 'Carregando Valores',
listWidth: 300,
maxHeight: 130
})
I want to, after the selection of a value in this combobox, change de value from de columns of the grid with the values from the combobox store.

Someone can help me?