How to blank a combo in an Editor Grid?
http://extjs.com/forum/showthread.php?t=28077
Is there a relatively easy way to address this problem?
Thanks.
-------------------------------------------------------------------------------
I have a an editor grid that is very similar to the one in Ext examples here: http://extjs.com/deploy/dev/examples...edit-grid.html
What I am trying to do is clear a field that has a ComboBox underneath. For example in the above example when you blank a field, on "blur" it gets populated back with the original value. I have tried adding allowBlank and all kinds of other options to the ComboBox and or Ext.Editor and nothing seems to work.
editor: new Ext.form.ComboBox({
typeAhead: true,
triggerAction: 'all',
transform:'light',
lazyRender:true,
allowBlank: true,
forceSelection: false,
validateOnBlur: false,
validationEvent: false,
emptyText: "Me Empty"
}
Its late at night and I must be missing something obvious. Any pointers in the right direction will be much appreciated.
Thanks.
My combo is not a transformed combo and is tied to a data store and it behaves exactly like the one in this example: http://extjs.com/deploy/dev/examples/grid/edit-grid.html
What are you doing differently that allows your combos (in-editor-grid) to clear?
Sure. Here is a simplified and modified version of the official Ext editor grid example that uses a ComboBox with a data store instead of a transform. When I try this in both IE 6 and FF 2.x I am unable to blank the combobox. I have tried a different variations of this script with no luck. I am probably overlooking something very small somewhere.
Ext.onReady(function(){
var lights = new Ext.data.SimpleStore({
fields: ['id', 'light'],
id:0,
data : [
['0', "Shage"],
['1', "Mostly Shady"],
['2', "Sun or Shade"],
['3', "Mostly Sunny"],
['4', "Sunny"]
]
});
function formatLight(value){
if (value) {
return lights.getById(value).get('light');
}
else {
return '';
}
}
var cm = new Ext.grid.ColumnModel([{
header: "Light",
dataIndex: 'id',
width: 130,
renderer: formatLight,
editor: new Ext.form.ComboBox({
valueField: 'id',
displayField:'light',
triggerAction: 'all',
store: lights,
lazyRender:true,
mode: 'local',
selectOnFocus:true,
typeAhead: true
})
}]);
var store = new Ext.data.SimpleStore({
fields: ['id'],
id:0,
data : [['1']]
});
// create the editor grid
var grid = new Ext.grid.EditorGridPanel({
store: store,
cm: cm,
renderTo: 'editor-grid',
width:200,
height:100,
title:'Edit Plants?',
frame:true,
clicksToEdit:1
});
});
Thanks. Your assistance in resolving this issue is much appreciated.
var cm = new Ext.grid.ColumnModel([{
header: "Light",
dataIndex: 'id',
width: 130,
renderer: formatLight,
editor: new Ext.form.ComboBox({
displayField:'light',
valueField: 'id',
triggerAction: 'all',
allowBlank:true,
store: lights,
lazyRender:true
,mode: 'local'
,listeners:{
blur:{fn:function() {
if(!this.getRawValue()) {
this.setValue();
}
}}
}
,selectOnFocus:true
,typeAhead: true
})
}]);
The main problem is that even if you clear text of combo it retains it underlying value. The above listener clears the value if the input text box is blank.
var cm = new Ext.grid.ColumnModel([{
header: "Light",
dataIndex: 'id',
width: 130,
renderer: formatLight,
editor: new Ext.form.ComboBox({
displayField:'light',
valueField: 'id',
triggerAction: 'all',
allowBlank:true,
store: lights,
lazyRender:true
,mode: 'local'
,listeners:{
blur:{fn:function() {
if(!this.getRawValue()) {
this.setValue();
}
}},
specialkey:{fn:function(field, e) {
if ((keyPressed == e.ENTER) && (!this.getRawValue())) {
this.setValue();
}
}}
}
,selectOnFocus:true
,typeAhead: true
})
}]);
Thanks in advance.
var lights = new Ext.data.SimpleStore({
fields: ['id', 'light'],
id:0,
data : [
[null,'---'],
['0', "Shage"],
['1', "Mostly Shady"],
['2', "Sun or Shade"],
['3', "Mostly Sunny"],
['4', "Sunny"]
]
});
However this brings up another question. I dont know how to easily hide a grid row. I usually remove the underlying record in the store, but in this case that is not an option.
Thanks.
I was trying many things but the only solution that is somehow workable is to add a "blank" record to combo. Such as:
var lights = new Ext.data.SimpleStore({
fields: ['id', 'light'],
id:0,
data : [
[null,'---'],
['0', "Shage"],
['1', "Mostly Shady"],
['2', "Sun or Shade"],
['3', "Mostly Sunny"],
['4', "Sunny"]
]
});
#If you have any other info about this subject , Please add it free.# |

