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

hot to know x and y coordinate of cell within grid.

1 Answer 176 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shimab
Top achievements
Rank 1
Shimab asked on 04 Nov 2011, 08:47 AM
We have requirement to use x and y coordinate of cell within radgrid.

Please suggest on it that how to get this.


Thanks
Shimab

1 Answer, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 09 Nov 2011, 10:31 AM
Hello Shimab,

Can you specify exactly what kind of coordinates you need to find out? Is it the number of the column and row to which a given cell belongs to, or just the offset of the cell in pixels from the top of the grid or the whole document. In all cases you will need some custom client-side code in order to achieve it.
For example you can get the number of the row for a particular cell by going up the DOM hierarchy until you reach the <tr> element to which the table cell belongs to, then you can parse its id (of type RadGrid1_ctl00__3) of which the last part is the item id ( 3 ). Once you have the item you can iterate over its cells by column name (using the get_cell method) until the content matches that of the given cell then you have the desired column.
As for the other way you can get the offset in pixels of the table cell element by traversing its parent elements and summing the offsetLeft and offsetTop values (as shown in this article) or simply use the jQuery position() method that is cross-browser and returns the same data.

Regards,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
Shimab
Top achievements
Rank 1
Answers by
Marin
Telerik team
Share this question
or