admin管理员组文章数量:1390503
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');
},
本文标签: javascriptKendoUI GridSelect text on cell focusStack Overflow
版权声明:本文标题:javascript - KendoUI Grid - Select text on cell focus - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744752084a2623241.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论