Check out the HACK!!! that I do: http://dojo.telerik.com/@Stephen/oxuSo
I've just taken the demo for inline editing and added my HACK!!! for textboxes and numericspin boxes(which is all this demo has).
The HACK!!! works for grids but it also works for "loose" controls as well, i.e. a widget just on your form.
The textbox HACK!!! just attaches a global handler on the focus event of .k-textbox element and selects() the contents.
The NumericTextBox(or ComboBox or DatePicker, etc) is where the magic happens.
//Custom NumericTextBox extentions.
(
function
($, undefined) {
//Get a reference to the NumericTextBox init method to
//call from within the custom control
var
x = kendo.ui.NumericTextBox.fn.init;
var
MyNumericTextBox = kendo.ui.NumericTextBox.extend({
init:
function
(element, options) {
var
numericTextBox =
this
;
x.call(numericTextBox, element, options);
numericTextBox.element.on(
"focus"
, numericTextBox._getFocus);
},
_getFocus:
function
(e) {
var
input = $(
this
);
setTimeout(
function
() {
input.select();
});
}
})
kendo.ui.plugin(MyNumericTextBox);
})(window.kendo.jQuery);
What this does is creates your own widget derived from the desired kendo widget that simply adds the focus handler to do the selection in the init/constructor.
Then it registers the widget as a plugin...BUT...because I didn't add the options configuration for the widget to give it a new name(http://docs.telerik.com/kendo-ui/intro/widget-basics/create-custom-kendo-widget#add-options), it overwrites/replaces the built-in NumericTextBox with mine so that all existing code that uses .kendoNumericTextBox() or Html.Kendo().NumericTextBox(), etc still works as the new widget has the same name as the built-in one, just with the tweak to the init to attach the focus handler.
I have a custom widget defined like this for each kendo widget that has an input with contents that should be selected on focus.
Note: the javascript that defines the custom widget should be after the main kendo.all.min.js but *before* the kendo.aspnetmvc.min.js. The MVC script adds some custom methods to the base widget that get blown away by this HACK!!! if you define your widget after the MVC script has done its thing.
This technique may not be pretty but it's been working pretty well.