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

CommandItem Event Capture Grid Filters/grouping

4 Answers 58 Views
Grid
This is a migrated thread and some comments may be shown as answers.
clint
Top achievements
Rank 1
clint asked on 25 Aug 2016, 05:55 PM

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!

 

 

 

 

4 Answers, 1 is accepted

Sort by
0
clint
Top achievements
Rank 1
answered on 25 Aug 2016, 06:15 PM

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
            }
}

 

0
Eyup
Telerik team
answered on 30 Aug 2016, 12:23 PM
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.
0
clint
Top achievements
Rank 1
answered on 30 Aug 2016, 02:56 PM

Hi Eyup,

 

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

0
Accepted
Eyup
Telerik team
answered on 05 Sep 2016, 05:14 AM
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.
Tags
Grid
Asked by
clint
Top achievements
Rank 1
Answers by
clint
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or