Apr 11, 2013, 4:14 PM
[CLOSED] Numberfield cant receive focus
Hello members
I was wondering if anybody have come a cross this problem before.
I have a field that can not recive focus after a form has been closed and then the same form is reopened.
the senario is that when i open the form for the first time my field can recive focus and marks the text.
But after i have made a submit / save of the data and reopens the form again the field cant recieve focus.
i have not override the fields default OnFocus method since i rely on the default implementation and use SelectOnFocus.
My Field code looks like this..
Regards
Peter
I was wondering if anybody have come a cross this problem before.
I have a field that can not recive focus after a form has been closed and then the same form is reopened.
the senario is that when i open the form for the first time my field can recive focus and marks the text.
But after i have made a submit / save of the data and reopens the form again the field cant recieve focus.
i have not override the fields default OnFocus method since i rely on the default implementation and use SelectOnFocus.
My Field code looks like this..
this.ID = Name + "_Time";
this.MaxValue = Convert.ToDouble("23,59");
this.MinValue = Convert.ToDouble("00,00");
this.Step = 0.01;
this.FieldLabel = label;
this.SelectOnFocus = true;
this.Listeners.Blur.Fn = "LIA.Time.OnBlur";
this.Listeners.Spin.Fn = "LIA.Time.Change";
this.CustomConfig.Add(new ConfigItem("type", "liaTimeField", ParameterMode.Value));
this.CustomConfig.Add(new ConfigItem("forcePrecision", "true", ParameterMode.Value));
My javascript methods are af following..
LIA.Time.Change = function () {
this.valueToRaw();
}
LIA.Time.OnBlur = function () {
this.valueToRaw();
}
I have overriden the methode valueToRaw and the code is like this.
// Overrides Numberfield decimals precision
Ext.override(Ext.form.NumberField, {
forcePrecision: false,
valueToRaw: function (value) {
var me = this,
decimalSeparator = me.decimalSeparator;
value = me.parseValue(value);
value = me.fixPrecision(value);
value = Ext.isNumber(value) ? value : parseFloat(String(value).replace(decimalSeparator, '.'));
if (isNaN(value)) {
value = '';
} else {
if (me.type == "liaTimeField") {
var hourIndex = String(value).indexOf(".");
if (hourIndex == -1) {
var hours = value;
}
else {
var hours = String(value).substring(0, String(value).indexOf("."));
}
var step = me.step;
var stepIndex = String(step).indexOf(".") + 1;
var stepDecimal = String(step).substring(stepIndex, String(step).length);
var decimalIndex = String(value).indexOf(".") + 1;
var decimals = String(value).substring(decimalIndex, String(value).length);
var diff = 0;
if (decimals.length < 2) {
if (decimalIndex == 0) {
decimals = "00";
}
decimals += "0";
}
if (parseInt(decimals) > 59) {
if ((parseInt(decimals) + parseInt(stepDecimal)) >= 100) {
var number = (parseInt(decimals) + parseInt(stepDecimal));
var diffNumber = number - 100;
var diff = 60 - (parseInt(stepDecimal) - diffNumber);
}
else {
var diff = decimals - 60;
hours++;
if (diff < 10) {
diff = "0" + diff;
}
}
value = me.parseValue(hours + "." + diff);
}
}
value = me.forcePrecision ? value.toFixed(me.decimalPrecision) : parseFloat(value);
if (me.type == "liaTimeField") {
if (hours < 10) {
value = String(value);
value = "0" + value;
}
}
value = String(value).replace(".", decimalSeparator);
}
return value;
}
})
Its not a game breaker for me, but i could lead to some unexspecting problem when a person tries to store a given time.Regards
Peter
Last edited by Daniil; Apr 30, 2013 at 4:13 AM.
Reason: [CLOSED]