Showing combobox option instead of value in editor grid for extjs
While working with Editor Grid of ext js, I noticed that if a combobox is used in some column for editing, then it shows the option value instead of label. This forces you to keep option label and value same. But this is not possible always.
Searching the extjs forum for this problem, I got a hint from one of the post to use renderer in this situation.
To make this work, you first have to fetch all the options of the combobox and create a Javascript array through it which can then be used in renderer function.
-
var comboVals = document.getElementById('combo-id').options;
-
-
var comboArr = new Array;
-
-
for (var i = 0; i <comboVals.length; i++) {
-
comboArr[comboVals[i].value] = comboVals[i].text;
-
}
Now write a renderer function like,
-
var comboRenderer = function (val) {
-
if (comboArr[val] != undefined) {
-
return comboArr[val];
-
} else {
-
return val;
-
}
-
}
The above function will return the label for the selected value if found the array otherwise it will simply return the value itself.
About this entry
You’re currently reading “ Showing combobox option instead of value in editor grid for extjs ,” an entry on SANIsoft - PHP for E Biz
- Published:
- 6.6.07 / 11am
- Category:
- Extjs, HowTo, Javascript
- Author:
- Aditya Mooley
No comments
Jump to comment form | comments rss | trackback uri