The cell content selection works successfully for a numeric text box (internally handled as a Kendo NumericTextBox control) but for some reason, it doesn't work with a plain textbox column. Attached is the jsfiddle demo'ing the issue:
This is the code in the grid setup that's of importance:
edit: function (e) {
var input = e.container.find("input");
input.focus(function (e) {
console.log('focus');
setTimeout(function () {
input.select();
});
});
}
The cell content selection works successfully for a numeric text box (internally handled as a Kendo NumericTextBox control) but for some reason, it doesn't work with a plain textbox column. Attached is the jsfiddle demo'ing the issue:
http://jsfiddle/latenightcoder/TrJVK/86
This is the code in the grid setup that's of importance:
edit: function (e) {
var input = e.container.find("input");
input.focus(function (e) {
console.log('focus');
setTimeout(function () {
input.select();
});
});
}
Share
Improve this question
asked Jul 29, 2013 at 21:14
Joel D'SouzaJoel D'Souza
9766 silver badges15 bronze badges
2 Answers
Reset to default 6It turns out that the focus event was getting fired before I could even wire up the focus event handler. So this was the optimal solution to support all types of fields within the grid row:
var input = e.container.find("input");
setTimeout(function () {
input.select();
}, 25);
The modified jsfiddle can be viewed here: http://jsfiddle/latenightcoder/TrJVK/90
You're only attaching the focus event handler to it, but you're not actually telling it to focus. The question should be, why does the kendo number box do it? :-) Also, setTimeout's 2nd argument isn't optional (according to spec).
Try the following (http://jsfiddle/TrJVK/87/)
edit: function (e) {
var input = e.container.find("input");
input.focus(function (e) {
// var input = $(this);
console.log('focus');
input.select();
});
input.focus();
},
One more note:
For future jQuery patibility, it might be best to do the following even:
edit: function (e) {
var input = e.container.find("input");
input.on('focus', function (e) {
// var input = $(this);
console.log('focus');
input.select();
});
input.trigger('focus');
},
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744752085a4591659.html
评论列表(0条)