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

RadGrid for ASP.NET AJAX and GridButtonColumn

3 Answers 210 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 1
Bob asked on 24 May 2008, 09:16 PM
I have a RadGrid in a DNN module which the first column is a GridButtonColumn called Report.  If the user clicks Report button a Crystal Report is displayed on seperate window not within DNN.  The user can view print or export the report.

Well this worked fine until I finally got AJAX working in DNN.  I was registering a startup script after capturing in a session variable the row clicked identified.  In the RadGrid ItemCommand event I identified it was the button pressed which still works but now I can not because of AJAX register a script to run.  I tried just adding a function on the User Control but have not figured out how I can call this function from the ItemCommand event.  I read how to do Callbacks and they act like I need...the client passes back to the server information on what was requested and them the callback fires back a function on the client with passed arguments. 

It would be nice if I could make RadGrid fire a function OnClicked for GridButtonColumn but have found no way of redirecting the event to a client function.  The javascript on the client is:

<
script type="text/javascript">
    function
OpenReport(arg, context)
    {
         window.open(arg,
"_blank","width=700, height=500, scrollbars=yes, menubar=no, resizable=1");
    }
</script>

and the partial code behind for RadGrid ItemCommand is:

If e.CommandName = "Report" Then
    Dim dataItem As GridDataItem = CType(e.Item, GridDataItem)
    If dataItem("Rev").Text <> "1" Then
        Dim pagePath As String = Me.ResolveUrl("Report.aspx")
        Session(
"rptID") = dataItem("ID").Text
        Session(
"rptRev") = dataItem("Rev").Text

        ????????? DO NOT KNOW HOW TO CALL FUNCTION OpenReport ???????

    End
If
End If

Can you please lead me in the right direction?

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 26 May 2008, 07:36 AM
Hi Bob,

Try the following code snippet.


ASPX:
<telerik:GridButtonColumn HeaderText="Click" Text="Click" UniqueName="Click">  
                    </telerik:GridButtonColumn> 

CS:
 protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)  
    {  
        if (e.Item is GridDataItem)  
        {  
            GridDataItem item = (GridDataItem)e.Item;  
            item["Click"].Attributes.Add("OnClick", "return OpenReport();");  
 
        }  
 
    }  
 


JS:
     <script type="text/javascript" language="javascript">  
      function OpenReport()  
       {  
      
       }  
     
   </script> 

Thanks
Princy.
0
Bob
Top achievements
Rank 1
answered on 26 May 2008, 01:05 PM

I have some reformating to do but that will definitely work.  Can I do this on the ItemCreated event?

Item["Click"]Attributes("Onclick") = [String].Format("return ShowForm('{0}','{1}','{2}');", e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("ID"), e.Item.ItemIndex, pagePath)

0
Shinu
Top achievements
Rank 2
answered on 27 May 2008, 05:38 AM
Tags
Grid
Asked by
Bob
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Bob
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or