Reputation: 986
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.net/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();
});
});
}
Upvotes: 2
Views: 5569
Reputation: 986
It 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.net/latenightcoder/TrJVK/90
Upvotes: 6
Reputation: 4110
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.net/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 compatibility, 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');
},
Upvotes: 0