Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
105
How to utilize XmlHTTPResponse
posted

Hi All,

I am exploring the AJAX support in Infragistics at the moment. Can anybody please explain how one can utilize XmlHTTPResponse in XmlHTTPRequestEventHandler method. On the click of a cell in a grid, i need to get an XML from the server and handle it on the client XmlHTTPResponseHandler function. If possible give and example (which lacks in Infragistics online help boo hoo hoo [:'(])

Please help.  

Thanks in Advance

-Shikha

Parents
  • 25
    posted

    This is the result of blood, sweat and tears.  The grid has a templated column with ASP buttons in a column.  I'm handling the click on the client side and using the AJAX call to perform processing asynchronously.  I hope the code is clear and helpful to you, and to others.

    //Server-side stuff

     protected void Grid_InitializeRow(object sender, RowEventArgs e)
     {
        UltraWebGrid stmGrid =  ( UltraWebGrid ) sender;
        printButton.Attributes[ "OnClick" ] = "return PrintStatus( '" + stmGrid.ID + "', " + e.Row.Index + " );";
     } 

    protected void DocumentGrid_XmlHTTPRequest( object sender, XmlHTTPRequestEventArgs e )
    {
       if ( e.Type == XmlHTTPRequestType.Custom && e.Data.ToString( ).Contains( "ReportName" ) )
       {
           UltraWebGrid stmGrid = sender as UltraWebGrid;
                   
           //… Lots of good stuff
       
           reportId = SomeFunction( );
                  
           stmGrid.ClientResponse.StatusMessage = string.Format( "reportId={0}", reportId );
       }
     }

    //Client-side stuff

    function PrintStatus( gridId, rowIndex )
    {
        var grid = igtbl_getGridById( gridId );
        var row = grid.Rows.getRow( rowIndex );  
        var params = "ReportName=PrintStatus";

        grid.invokeXmlHttpRequest( grid.eReqType.Custom, null, params );
        return false; //Don’t fire server-side event
    }

    function DocumentGrid_XmlHTTPResponseHandler(gridName, rowId, gridResponse)
    {
        //Add code to handle your event here.
        if ( gridResponse.StatusMessage.indexOf("reportId=") != -1 )
        {
            var windowName = gridResponse.StatusMessage.replace("reportId=","");
            windowName = windowName.replace(/-/g,"");
            window.open( "../Reports/ShowReport.aspx?" + gridResponse.StatusMessage
                        , windowName
                        , "width=450, height=450, resizable=1, scrollbars=1" );
         }
    }

     

Reply Children