-
7 Sep 2012 12:03 AM #1
Unanswered: display and value field in grid editor.
Unanswered: display and value field in grid editor.
I have a grid editor. And this grid editor has the two drop downs.
Where each dropdown has thedisplay field and value field. Initially the drop down display the display field but when I select value from drop downs it displays the selected value field. I want to display the selected display field and I have to save display field into database.
Please help to resolve this issue.
-
7 Sep 2012 1:13 AM #2Sencha - Community Support Team
- Join Date
- May 2012
- Location
- Istanbul
- Posts
- 1,331
- Vote Rating
- 76
- Answers
- 124
Hi,
may you provide your code for better understanding the problemsword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.
-
7 Sep 2012 1:18 AM #3
pipegroup = Ext.create('Ext.grid.Panel', {
store: pipegroupdatastore,
forceFit : true,
// height : 300,
columns: [
{
header: 'LOWER SIZE',
width : 60,
dataIndex: 'pipegrouplowersize',
//flex: 1,
editor: {
xtype : 'combo',
name : 'pmspipegrouplowersize',
id : 'pmspipegrouplowersize',
store : sizestore,
dataIndex: 'valuefield',
displayField: 'lowersize',
valueField: 'valuefield',
editable : false,
allowBlank: false
}
},
{
header: 'UPPER SIZE',
width : 60,
dataIndex: 'pipegroupuppersize',
//flex: 1,
editor: {
// defaults to textfield if no xtype is supplied
xtype : 'combo',
name: 'pmspipegroupuppersize',
id : 'pmspipegroupuppersize',
store : sizestore,
dataIndex: 'valuefield',
displayField: 'uppersize',
valueField: 'valuefield',
allowBlank: false,
editable : false
}
},
And sizestore
The json store looks like:
[{"valuefield":1,"lowersize":15,"uppersize":15},{"valuefield":2,"lowersize":20,"uppersize":20},{"valuefield":3,"lowersize":25,"uppersize":25}...........................]
-
7 Sep 2012 2:06 AM #4Sencha - Community Support Team
- Join Date
- May 2012
- Location
- Istanbul
- Posts
- 1,331
- Vote Rating
- 76
- Answers
- 124
Hi,
you can use renderer to particular column, tyr to use following code:
Code:{ header: 'LOWER SIZE', width : 60, dataIndex: 'pipegrouplowersize', / /flex: 1, editor: { xtype : 'combo', id : 'pmspipegrouplowersize', store : sizestore, displayField: 'lowersize', valueField: 'valuefield', , hiddenName:'pipegrouplowersize' editable : false, allowBlank: false }, renderer:function (value, metaData, record, rowIndex, colIndex, store) { var editor = yourgrid.getColumnModel().getCellEditor(colIndex, rowIndex) , field = editor.field , fieldRecord = field.findRecord(field.valueField, value); if (fieldRecord) { record.data[field.hiddenName] = value; value = fieldRecord.get(field.displayField); } return value; } }sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.
-
7 Sep 2012 2:23 AM #5
Thank you for your quick reply.
The code given by is givving error "Object doesnt support this property" for very first line of rendrer function.
I some where found the link similar to this:
http://www.learnsomethings.com/2010/...in-a-nutshell/
Its working.
But when I select the lowersize=15 actually it displaying 300 which is asccociated with 15 value field but the actual 15 value field is 0.
-
7 Sep 2012 2:34 AM #6Sencha - Community Support Team
- Join Date
- May 2012
- Location
- Istanbul
- Posts
- 1,331
- Vote Rating
- 76
- Answers
- 124
Hi,
try this line at the first line of renderer
var editor = yourgrid.getColumnModel().getCellEditor(colIndex, rowIndex);sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.
-
7 Sep 2012 2:44 AM #7
I tried like this.
renderer:function(value)
{
var index = sizestore.find("valuefield",value);
if(index!=-1)
{
var displayName = sizestore.getAt(index).get("lowersize");
}
return displayName;
}
but again it displying the assciated display name of that value. I am not saving value field in database. I have to save display field of record.
-
7 Sep 2012 3:12 AM #8
Try removing the data index from the combo's configuration and try.
I guess it should work then.
-
7 Sep 2012 3:38 AM #9
-
7 Sep 2012 4:04 AM #10
Yes Its working now.
Now I have different problem.
I have an javascript array for some requirement.
Now when is grid is loading or after loading the value of drop downs of that grid should be inserted
in that array.
I tried using rendrer but not getting values means i tried giving alert it giving null value and it gives alert twise.
please help me.


Reply With Quote