Reputation: 2761
I have a custom grid and some cells have a cell editor , an Ext.form.TextField, in order to modify value of the cell. Here is how is defined the TextField:
var labelTextEditor = new Ext.form.TextField({
allowBlank: false,
maxLength: 256,
id: "labelTextEditor",
maxLengthText: Label.conf.ui.javascript.TooLongText,
validateOnChange: true,
validator: function(value) {
console.log(value);
if (value == "" && value.trim() == "") {
return formatMessage(Label.conf.ui.supv.LabelMandatory);
} else
return true;
},
msgTarget: 'under',
listeners: {
focus( a, event, eOpts ){
var rowIndex = customFieldGrid.getSelectionModel().getCurrentPosition().row;
if(rowIndex !== undefined && rowIndex !== null){
a.setValue(view.listOfServiceDefinition[0].customFields[rowIndex].labels[userLanguagePrefix]);
}
},
blur(a, event, eOpts){
var cellValue = a.getValue();
if(cellValue !== undefined && cellValue !== null){
a.setValue(cellValue);
}else{
a.setValue("");
}
}
}
});
When I focus on the cell, it keeps me the value that was there before focusing on the cell, thanks to the focus listener. But when I lose focus, the cell displays nothing. When I click back on it, the value is displayed again and can be edited. So the problem is that when I lose focus, the value cannot be kept displayed on the cell. I've tried to blur event but didn't help...
Upvotes: 1
Views: 51
Reputation: 2423
Problem here is your blur
event. As Per Documentation blur event Fires when this Component loses focus. So in your case when you loosing focus your blur event is firing. And As I can see in your blur event You are setting some other values, Therefor it is coming as empty.
This line is causing an issue in your code :
else{
a.setValue("");
}
I also created one fiddler to understand blur
and focus
.
Upvotes: 2