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

Click hyperlink field - then show selected record

1 Answer 56 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 09 Dec 2008, 05:43 AM
Hi,

I have a field that once selected opens up a 'pop-up' for to allow editing of a record. Is there any way to show the record that was clicked on (show it as selected) for the pop-up. My users are finding that once they close down the pop-up they do not know what record they clicked on.

Thanks

Ryan

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 09 Dec 2008, 07:41 AM
Hi Ryan,

I guess you are using window editing and want the row as selected on clicking the HyperLink. You can try the following JavaScript in order to select the clicked row.

JavaScript:
 function ShowEditForm(id, rowIndex) 
  { 
     var grid = $find("<%= RadGrid1.ClientID %>");                  
     var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element();  
     grid.get_masterTableView().selectItem(rowControl, true);  
    ... 
  } 
 

CS:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
       if (e.Item is GridDataItem) 
       { 
           HyperLink editLink = (HyperLink)e.Item.FindControl("EditLink"); 
           editLink.Attributes["href"] = "#"
           editLink.Attributes["onclick"] = String.Format("return ShowEditForm('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["EmployeeID"], e.Item.ItemIndex); 
       } 

Please check out the online demo which having similar scenario.
Window Editing

Thanks,
Shinu.
Tags
Grid
Asked by
Ryan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or