PDA

View Full Version : It is still about the editor



wdw430
24 Apr 2008, 5:53 PM
I use the combox as the cell editor.
You know the combox has two field displayfiled and valuefield.
And when use the combox as grid editor,after edited.Is the cell as have two value,the display value and the underlying real value?
Is it the real value is saved in store of the grid,and the display value is performed through GridView?
Thank you.

24 Apr 2008, 7:58 PM
the 'value' is not what's shown by the 'renderer'.

I just confirmed this on a project that i'm working on that uses an editor grid panel.


So when you look a the record.data, you'll see the actual Value for the combo box, not the rendered version.

Are you using a custom renderer btw?

wdw430
24 Apr 2008, 9:57 PM
the 'value' is not what's shown by the 'renderer'.

I just confirmed this on a project that i'm working on that uses an editor grid panel.


So when you look a the record.data, you'll see the actual Value for the combo box, not the rendered version.

Are you using a custom renderer btw?


呵呵:)
I just to want show the display value and store the real value in the store of grid,because i need to define a class like combox.But I am not clear what is is realised? So can you give some advise or tell me to read some code?
Thank you

wdw430
24 Apr 2008, 10:23 PM
The fellowing is a frangment code in EditorGridPanel,you can see i add a alert code in it.And i see the value which is set in the store of the grid is just the display value in the combox.So the real value in the combox is not set.It is conflicted with what i thought before.Is there any wrong place?


onEditComplete : function(ed, value, startValue){


this.editing = false;
this.activeEditor = null;
ed.un("specialkey", this.selModel.onEditorKey, this.selModel);
if(String(value) !== String(startValue)){
var r = ed.record;
var field = this.colModel.getDataIndex(ed.col);
var e = {
grid: this,
record: r,
field: field,
originalValue: startValue,
value: value,
row: ed.row,
column: ed.col,
cancel:false
};
if(this.fireEvent("validateedit", e) !== false && !e.cancel){

alert(e.value);
r.set(field, e.value);




};

//if(this.fireEvent("afteredit", e)!== false&& !e.cancel){
// r.set(field, e.value);

// alert("what value:"+e.value);

// delete e.cancel;

// }
}
this.view.focusCell(ed.row, ed.col);
},

tarini
28 Apr 2008, 5:28 AM
I have the same problem with a store with 2 fields ("label" and "field") and I want to show in the ComboBox the "label" but to save in the store the "field".

I created the editor properties in this way


editor: new Ext.form.ComboBox({
allowBlank: false,
store: myTwoFieldStore,
valueField: 'field',
displayField: 'label',
mode: "local",
typeAhead: false,
editable: false
})


When I select an option from the combo it has the correct "label"s.
If I choose one of these it saves correctly the "field" in the underlying store, but shows "field" on the grid instead of the "label"...

I think it's not the right behaviour

Have you find a solution for this??

wdw430
29 Apr 2008, 7:30 PM
I have the same problem with a store with 2 fields ("label" and "field") and I want to show in the ComboBox the "label" but to save in the store the "field".

I created the editor properties in this way


editor: new Ext.form.ComboBox({
allowBlank: false,
store: myTwoFieldStore,
valueField: 'field',
displayField: 'label',
mode: "local",
typeAhead: false,
editable: false
})


When I select an option from the combo it has the correct "label"s.
If I choose one of these it saves correctly the "field" in the underlying store, but shows "field" on the grid instead of the "label"...

I think it's not the right behaviour

Have you find a solution for this??


Yes, i met the same problem when the application is complex.
NOw i want to read the core code,so that i can find a way.

Animal
30 Apr 2008, 1:30 AM
Either use a renderer in your grid, and store the value in the Record.

Or return false to the validateedit event, but set the display field from the Combo into the Record yourself.

It's not that difficult.