This is a migrated thread and some comments may be shown as answers.

HowTo: Select the value of the textbox in the cell Im editing.

0 Answers 114 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Pär
Top achievements
Rank 1
Pär asked on 06 Nov 2012, 12:01 PM
It took me a while to figure this out, so I thought a post here about it wouldn't hurt. I really think this should be a parameter in the grid.
In my version (2012.2.710.340), when Im editing a cell, the marker places itself on position 0, before the value. Because of this, the user has to manually select and delete the value of the textbox before entering anything. Since we're all a bunch of lazy bastards, this just won't work :). When I click a cell, I want the value to be selected, so that I just start typing to replace it.

To achive this, just add a hook on the "edit"-event like this.

<script type="text/javascript">
    $(function () {
        // get a reference to the grid
        var grid = $("#@gridname").data("kendoGrid");
 
        grid.bind("edit", function (e) {
            e.container.find("input").select();
        });
    });
</script>

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Pär
Top achievements
Rank 1
Share this question
or