PDA

View Full Version : EditorGrid with RadioGroup, how to name the field?



djhonyy
10 Nov 2009, 8:18 AM
Hi folks,

my first thread :) sorry for my english ok?

i have an editorGrid, this grid have 2 columns, one of then is editable, the editor is a radiogroup with two items, but i cant use it properly because i dont know how to name the field. the name must be a value from the actual record.

question, how to get the actual index from record during the render?

Arcadius
10 Nov 2009, 9:09 AM
I'm not sure if this will solve the problem, but it may be a start.
You have your radiogroup, something like this;
xtype: 'radiogroup',
id: 'idNameHere',
width: 150,
items: [
{boxLabel: 'LabelName1', name: 'rg', inputValue: 'Value1Here', checked: true},
{boxLabel: 'LabelName2', name: 'rg', inputValue: 'Value2Here'}
]

Where you should set the id to something relevant, change the boxLabels or get rid of them completely, and change the inputValue to the actual values you need.

After this, you should be able to access the value that is selected using;
Ext.getCmp('idNameHere').getValue().getGroupValue()
obviously replacing idNameHere again with your whatever you chose.

I hope this is a start for your.

djhonyy
10 Nov 2009, 9:25 AM
Hey Arcadius, i already tried this option, but my problem occours during the render and not after it.


for each iteration I need to access the current index of the store and retrieve a specific value, this value is the name of radiogroup.


here is my code, in the secnod column, called "Importação Ativa", this column must be able to access the record to get value "Agencia", and set this own name.


//##############################################################################
//##############################################################################
//##############################################################################
//Ext.grid.EditorGridPanel
this.gridColumnModel = new Ext.grid.ColumnModel([{
header: 'Cooperativa',
id: this.value,
dataIndex: 'Agencia',
width: 350,
renderer: function(value, metadata, record, rowIndex, colIndex, store)
{
this.codigoAgencia = value;
return value + " - "+ record.get('Nome').replace("SICOOB/SC - ","");
}

},{

header: 'Importação Ativa',
dataIndex: 'ImportacaoAtiva',
width: 150,
align: 'left',
renderer: function(value, metadata, record, rowIndex, colIndex, store)
{
return (value == "S") ? "Ativo" : "Inativo";
},
editor: new Ext.form.RadioGroup({
hideLabel: true,
itemCls: 'x-check-group-alt',
items:
[{
boxLabel:'Ativo',
name: /* WHERE I WANT TO ACCESS THE ACTUAL INDEX RECORD OF THE ITERATION AND GET THE AGENCY VALUE*/,
inputValue:"S"
},{
boxLabel:'Inativo',
name: /* WHERE I WANT TO ACCESS THE ACTUAL INDEX RECORD OF THE ITERATION AND GET THE AGENCY VALUE*/,
inputValue:"N"
}]//items
})//fim radioGroup
}
]);

// Cria o storage
this.dataStoreStatusImportacaoCooperativas = new Ext.data.Store({
proxy : new Ext.data.MemoryProxy(this.formData),

reader : new Ext.data.JsonReader({
root : 'statusCooperativas'
},

Ext.data.Record.create([
{name : 'Agencia', type : 'string'},
{name : 'Nome', type : 'string'},
{name : 'ImportacaoAtiva', type : 'string'}
])),

autoLoad: true
});


// create the editor grid
this.gridPanel = new Ext.grid.EditorGridPanel({
store: this.dataStoreStatusImportacaoCooperativas,
cm: this.gridColumnModel,
width: 630,
height: 100,
clicksToEdit: 1

});
//Ext.grid.EditorGridPanel
//##############################################################################
//##############################################################################
//##############################################################################

Arcadius
10 Nov 2009, 11:19 AM
I am not quite certain what you are trying to do exactly. But the name: of a radio button is not what is output on the screen. Since you have 2 radio buttons, I assume you only want one to be selected at any given time? If so, just make the name: of both of the buttons the same, like I did in my previous post. name: 'rg' for both would do.
InputValue is the value that will actually be shown, but again, I am not sure where you need to get this info from.

djhonyy
10 Nov 2009, 11:28 AM
my problem.

im in the editor, with the radiogroup, to configure him i need to access the actual record, to get some values that needed to configure this radiogroup. when my radiogroups are proplerly configured, the user will make the changes he want and will submit the form, the edited radios will update the table.

i dont know how to access the actual record, i just need to do some like the code above:

Ext.radiogroup({
name: record.get('any record index from the actual iteration')
});