Welcome Guest Search | Active Topics | Sign In | Register

Highlight GridCell Contents Options
Chris Beckingham
Posted: Monday, July 26, 2010 8:22:15 PM
Rank: Newbie
Groups: Member

Joined: 1/13/2010
Posts: 4
When the user clicks in a field to edit it when FullRowMode="false" I want the contents of the field to be highlighted (so the user can just start typing and the old value will be overwritten).

Is this possible?

It looks like I should use ClientSideOnCellSelected() and then GetSelectedCell() to grab the cell and then just highlight it. But that last step is beyond me apparently.

Thanks
Chris
eo_support
Posted: Monday, July 26, 2010 8:41:36 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Yes. ClientSideOnCellSelected is the correct way to go. You can use the following code:

Code: JavaScript
function select_cell(grid)
{
    //Get the selected cell
    var selectedCell = grid.getSelectedCell();

    //Get the column index of the selected cell
    var colIndex = selectedCell.getColIndex();

    //Get the ID of the textbox used for that column. This line is
    //the key because there is no public interface for you to access
    //this textbox. Note this code is for TextBoxColumn only
    var textBoxId = grid.getId() + "_c" + colIndex + "_edit_tb";

    //Get the textbox used for that column. Note the Grid reuses
    //the same editing UI for all rows. So there is only one textbox
    //per column
    var textBox = document.getElementById(textBoxId);

    //Highlight the text in the textbox. The call is delayed with
    //a timer so that the Grid can finishes updating its internal
    //data first
    setTimeout(function()
    {
        textBox.select();
    }, 10);
}


Code: HTML/ASPX
<eo:Grid ClientSideOnCellSelected="select_cell" ....>
....
</eo:Grid>


Hope this helps. Please feel free to let us know if you have any question.

Thanks!
Chris Beckingham
Posted: Monday, July 26, 2010 9:20:05 PM
Rank: Newbie
Groups: Member

Joined: 1/13/2010
Posts: 4
Yep that did the trick. Thanks for the quick assistance.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.