RadGrid for ASP.NET AJAX and GridButtonColumn

4 posts, 0 answers
  1. Bob
    Bob avatar
    21 posts
    Member since:
    Mar 2008

    Posted 24 May 2008 Link to this post

    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?

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 26 May 2008 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Bob
    Bob avatar
    21 posts
    Member since:
    Mar 2008

    Posted 26 May 2008 Link to this post

    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)

  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 May 2008 Link to this post

Back to Top