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

How do I select a specific cell in dataBound event

2 Answers 747 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chombito
Top achievements
Rank 1
Chombito asked on 14 Feb 2013, 08:59 PM
Hi!

I want to select a cell after the grid is displayed. How do I select a specific cell based on the column index and row index in the dataBound event?

Thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
Alexander Valchev
Telerik team
answered on 18 Feb 2013, 09:10 AM
Hi Chombito,

Thank you for getting in touch with us.

To achieve that you select the corresponding cell (<td> element) from grid's content using jQuery. After the cell is found you can simply pass it to the select method of the grid. All cells of the current page are rendered when the dataBound event fires. As an example:
dataBound: function (e) {
  var rowIndex = 2, //zero based
      colIndex = 1, //zero based
      cell,
      grid = this;
 
    cell = grid.tbody
          .find(">tr")
          .eq(rowIndex)
          .find(">td:nth-child(" + (colIndex + 1) + ")");
   
    grid.select(cell);
}

You can test the solution here: http://jsbin.com/atigik/2/edit
For more information please check the jQuery selectors API reference: http://api.jquery.com/category/selectors/

Kind regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Chombito
Top achievements
Rank 1
answered on 18 Feb 2013, 09:00 PM
That's the way to do it. Thanks!
Tags
Grid
Asked by
Chombito
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Chombito
Top achievements
Rank 1
Share this question
or