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

Open Window on Grid RowClick

3 Answers 63 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steve Humby
Top achievements
Rank 1
Steve Humby asked on 30 Jan 2009, 01:14 PM
Hi All

I have a grid which contains an edit button that when clicked, opens a RadWindow which allows me to add/edit/remove data. I'm using the approved Telerik code as provided on the demos page (below):

If

 

TypeOf e.Item Is GridDataItem Then

 

 

Dim editLink As HyperLink = DirectCast(e.Item.FindControl("EditLink"), HyperLink)

 

 

Dim linkParams As String = "?aid=" & e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("AssignmentID")

 

editLink.Attributes(

"href") = "#"

 

editLink.Attributes(

"onclick") = String.Format("return ShowEditForm('{0}','{1}');", linkParams, e.Item.ItemIndex)

 

 

End If

 


All works really well but what I would really like to do is raise the same event on the grid's RowClick command (ie remove the linkbutton and just raise the window when the user clicks on the relevant row, maybe something that casts the row into a hyperlink itself?).

JavaScript isn't my strong point and so I wondered if anyone else had found a solution to this?

Thanks in advance.

Steve :o)


3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 02 Feb 2009, 05:52 AM
Hello Steve,

Try out the following code to display a window on clicking a row:
vb:
 Protected Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs) 
         If TypeOf e.Item Is GridDataItem Then 
             Dim dataItem As GridDataItem = DirectCast(e.Item, GridDataItem) 
             Dim linkParams As String = "?aid=" & e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("AssignmentID")  
             dataItem.Attributes("onclick") = [String].Format("return ShowEditForm('{0}','{1}');", linkParams , dataItem.ItemIndex) 
         End If 
     End Sub 
 

Thanks
Princy.
0
Steve Humby
Top achievements
Rank 1
answered on 02 Feb 2009, 11:21 AM
Thanks Princy, it opens the window but then closes again after an Ajax event appears to fire.
The next time I click on the row, a window opens but not in the size that I have created in the Window Manager, then closes again.
Very strange.
:o)
0
Steve Humby
Top achievements
Rank 1
answered on 03 Feb 2009, 09:37 AM
Oops, found a stray tick in AjaxManager that was causing the form to be submitted twice.

Works perfectly, thanks mate. :o)
Tags
Grid
Asked by
Steve Humby
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Steve Humby
Top achievements
Rank 1
Share this question
or