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

Server side loop through visible rows

3 Answers 46 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 08 Oct 2008, 04:51 PM
I have a feeling this should be simple but I can't for the life of me get my head around it.

I want a clientside doubleclick event to do a simple javascript window.open() with the URL derived from data in the grid row clicked.

My first javascript function looked like this:
function RowDblClick(sender, eventArgs) {  
switch (eventArgs.get_itemIndexHierarchical()) {  
 case '0':  
    window.open('urlhere','','')  
 case '1':  
  ....etc  
 
}  
}  
 

Simple enough. The calculation of the URL is quite intensive so I don't want to do it more than I have to, so what I want to do is loop through the visible rows
and generate the code I need.

Any help would be appreciated

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 09 Oct 2008, 05:47 AM
Hello Paul,

You can use ItemCreated or ItemDataBound to achieve this:

if(e.Item is GridDataItem)
{
    e.Item.Attributes["ondblclick"] = "yourFunction";
}

Kind regards,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Paul
Top achievements
Rank 1
answered on 10 Oct 2008, 08:51 PM
Many thanks for the response, but unfortunately I already thought of that.
The grid is only part of the page (its on a radTab actually), its sharing with a conventional form.
Now ItemDataBound apparently isnt fired on a page postback, so when I submit the form the page reloads without triggering the itemdatabound event and the javascript never gets compiled.
So it only works when the page is first opened.

Any other approach I can use?
Remember that there could be hundreds of rows in the grid in total, and the calculation for which page to open is quite intensive so I only want to loop through the visible rows if possible.
0
Vlad
Telerik team
answered on 13 Oct 2008, 06:21 AM
Hello Paul,

You can use ItemCreated instead. If you need a value related to the current data item you can use DataKeyNames/DataKeyValues.

Sincerely yours,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Paul
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Paul
Top achievements
Rank 1
Share this question
or