PDA

View Full Version : TreePicker: StartEdit, DisplayField and ValueField



hiroprotagonist
2 Oct 2012, 5:08 AM
Guys,

the treepicker component (Ext.ux.TreePicker) simply does not consider the displayField and valueField config settings I introduced for it when starting edit with help of the cell editor plugin (Ext.grid.plugin.CellEditing) in a grid.

There are two main methods that seem to ignore these fields:
- The getEditor method of the plugin creates an instance of Ext.grid.CellEditor which get the field that is defined e.g. in the column header to edit a certain type of cell. So the CellEditor startEdit method is going to be used to start the editing process.
- The plugin's startEdit method calls the CellEditor's startEdit method with the element of the cell and a possible value that used as startvalue:



ed.startEdit(me.getCell(record, columnHeader), value);


The latter makes it impossible for the editor to determine the fields as there is simply no record passed. Additionally the Ext.ux.TreePicker component expects the value that is been set to be the id of the record to find the node by id.


/**
* Sets the specified value into the field
* @param {Mixed} value
* @return {Ext.ux.TreePicker} this
*/
setValue: function(value) {
var me = this,
record;

me.value = value;

if (me.store.loading) {
// Called while the Store is loading. Ensure it is processed by the onLoad method.
return me;
}

// try to find a record in the store that matches the value
record = value ? me.store.getNodeById(value) : me.store.getRootNode();
...


So editing is not possible in grid with the treepicker component.

Is there anything in the pipe that will solve these problems? I'll try myself by introducing a new method that willl pass the record but this certainly leads in overriding a lot of stuff.

Any help highly appreciated,

hiro.

mitchellsimoens
10 Oct 2012, 8:22 AM
Are you providing the configs for the treepicker?

hiroprotagonist
10 Oct 2012, 11:14 AM
Hi Mitchell,

do you mean value and display field config? Yes, sure I do.
I do have *some* issues here which I guess can hardly be unified from your side:
1. The tree certainly needs unique ids for populating. I do not want to show the ids, instead of the ids the names are shown.
2. Each level of the tree represents a different type of information. Thus for each a different editor is necessary. E.g. level 1 (just below the root level) is not editable, level 2 needs a combo box to select from a list, level 3 is edited by a textbox, level 4 shall be selected by a tree picker.
3. The editors are not prepared to pass over the record. Instead of the record the "pure" value is transported.

So I anyway had to do something on my own here.
I mainly solved it by
a) providing the record in setValue instead of the value of the cell itself.
b) overriding the setValue method of the controls I needed (combobox, tree picker, textbox) handling the record (coming from the editor) or the pure value (coming from the control when selecting)

Thanks for the answer anyway.

Hiro.