CommandItem Event Capture Grid Filters/grouping

5 posts, 1 answers
  1. clint
    clint avatar
    5 posts
    Member since:
    Jul 2015

    Posted 25 Aug Link to this post

    Hello,

     

    I have a radgrid where I added a button in the ItemCreated event for the grid.

     

    <p>if (e.Item is GridCommandItem)<br>            {<br>                ImageButton b = new ImageButton();<br>                b.ID = "Export";<br>                b.ImageUrl = "images/excel.png";</p><p>b.CommandName = "Export";</p><p>e.Item.Controls[0].Controls[1].Controls.Add(b);<br>            }</p>

     

    When the image is clicked it calls the ItemCommand event:

    protected void grdInventory_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)<br>        {<br>            if (e.CommandName == "Export")<br>            {<br>                 //do stuff<br> }<br>        }

     

    I want to capture the filters or grouping for that grid and export them to excel in that event.  I'd also like to ignore the paging.  I know there is a default exportToExcel button for these grids, but I need to export to a template.  Therefore, I want to write custom code in the ItemCommand event.  Unless there is something built into radgrid that will allow me to export the results to a predefined template?

     

    Thanks!

     

     

     

     

  2. clint
    clint avatar
    5 posts
    Member since:
    Jul 2015

    Posted 25 Aug in reply to clint Link to this post

    Sorry about the formatting...here it is again....

     

    protected void grdInventory_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
              if (e.Item is GridCommandItem)           
              {
                    ImageButton b = new ImageButton();
                    b.ID = "Export";
                    b.ImageUrl = "images/excel.png";
                    b.CommandName = "Export";
                    e.Item.Controls[0].Controls[1].Controls.Add(b);
              }
     
    }

     

    protected void grdInventory_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)       
    {
                if (e.CommandName == "Export")
                {
                    //do stuff
                }
    }

     

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Eyup
    Admin
    Eyup avatar
    3005 posts

    Posted 30 Aug Link to this post

    Hello Clint,

    You can apply any desired ExportSettings to the grid, then initiate Export command:
    protected void Button1_Click(object sender, EventArgs e)
    {
        RadGrid1.ExportSettings.IgnorePaging = true;
        RadGrid1.ExportSettings.Excel.Format = GridExcelExportFormat.Html;
        RadGrid1.MasterTableView.ExportToExcel();
    }

    I hope this will prove helpful.

    Regards,
    Eyup
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  5. clint
    clint avatar
    5 posts
    Member since:
    Jul 2015

    Posted 30 Aug in reply to Eyup Link to this post

    Hi Eyup,

     

    I need to take the results and export to a specific Excel template.  Is there something built into Telerik for this?

  6. Answer
    Eyup
    Admin
    Eyup avatar
    3005 posts

    Posted 05 Sep Link to this post

    Hi Clint,

    This requirement is not provided by RadGrid. You can check the Processing libraries included in the Telerik suite:
    http://demos.telerik.com/aspnet-ajax/wordsprocessing/convert-documents/defaultcs.aspx
    http://demos.telerik.com/aspnet-ajax/spreadprocessing/convert-documents/defaultcs.aspx
    http://demos.telerik.com/aspnet-ajax/pdfprocessing/overview/defaultcs.aspx

    Regards,
    Eyup
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017