I have a data grid that I'm exporting with filters.
I use two type of filters, "fill in the blank" and "combo box values". The ones that use "fill in the blank" are exported to excel correctly, they are in the first row of the datagrid. The filters that use "combo box values" do not show the selected value, the data is correctly filtered but the filter selection isn't shown in the first row.
Attached is an example of what I have and what I want.
I use two type of filters, "fill in the blank" and "combo box values". The ones that use "fill in the blank" are exported to excel correctly, they are in the first row of the datagrid. The filters that use "combo box values" do not show the selected value, the data is correctly filtered but the filter selection isn't shown in the first row.
Attached is an example of what I have and what I want.
8 Answers, 1 is accepted
0

Darren
Top achievements
Rank 1
answered on 21 Oct 2011, 09:03 PM
bump
Anyone have an idea? Do i need to add more detail?
Anyone have an idea? Do i need to add more detail?
0

Princy
Top achievements
Rank 2
answered on 24 Oct 2011, 06:26 AM
Hello Darren,
I have not find any issue for exporting the filtered data. Please make sure that you have used advanced data-binding for populating RadGrid.
Could you please paste your code for exporting the data?
Thanks,
Princy.
I have not find any issue for exporting the filtered data. Please make sure that you have used advanced data-binding for populating RadGrid.
Could you please paste your code for exporting the data?
Thanks,
Princy.
0

Darren
Top achievements
Rank 1
answered on 24 Oct 2011, 03:41 PM
var
tmpFileName =
"LHD - "
+ DateTime.Now.ToShortDateString() +
"_"
+
DateTime.Now.ToShortTimeString();
radSearchResults.ExportSettings.FileName = tmpFileName;</P>
radSearchResults.ExportSettings.Excel.Format =
GridExcelExportFormat.Html;
radSearchResults.MasterTableView.ExportToExcel();
That's the code that exports the filtered grid to an excel file.
0

Amy Liu
Top achievements
Rank 1
answered on 26 Oct 2011, 09:33 PM
I have the same problem for the filtertemplete.
see the link http://www.telerik.com/community/forums/aspnet-ajax/grid/how-to-show-and-hide-filter-in-excel-exported.aspx
see the link http://www.telerik.com/community/forums/aspnet-ajax/grid/how-to-show-and-hide-filter-in-excel-exported.aspx
0
Hello guys,
I assume the cause of the described issue is that all controls rendered as input are stripped from the exported file.
Please use the following code in order to implement the desired functionality:
I hope it helps.
Kind regards,
Mira
the Telerik team
I assume the cause of the described issue is that all controls rendered as input are stripped from the exported file.
Please use the following code in order to implement the desired functionality:
bool
isExport =
false
;
protected
void
Button1_Click(
object
sender, EventArgs e)
{
isExport =
true
;
//RadGrid1.Rebind(); //you need to uncomment this if IgnorePaging is false
RadGrid1.MasterTableView.ExportToExcel();
}
protected
void
RadGrid1_ItemCreated(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridFilteringItem && isExport)
{
//find the combobox and replace it with its value
}
}
I hope it helps.
Kind regards,
Mira
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0

Amy Liu
Top achievements
Rank 1
answered on 27 Oct 2011, 04:46 PM
Hi Thanks for reply.
It is very good.
I face another problem as I use the built-in exporttoexcel etc buttons. How could I get the status of the export button clicked?
Thanks for help!
Amy
It is very good.
I face another problem as I use the built-in exporttoexcel etc buttons. How could I get the status of the export button clicked?
Thanks for help!
Amy
0

Blake
Top achievements
Rank 1
answered on 27 Oct 2011, 06:28 PM
protected void rgSearchResults_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridFilteringItem && isExported)
{
DateTime? fromDate=null;
DateTime? toDate = null;
RadDatePicker fromControl = e.Item.FindControl("FromDatePicker") as RadDatePicker;
RadDatePicker toControl = e.Item.FindControl("ToDatePicker") as RadDatePicker;
fromDate = fromControl.SelectedDate;
toDate = toControl.SelectedDate;
TableCell cell = (e.Item as GridFilteringItem)["CreatedDate"];
cell.Text = fromDate + " To " + toDate;
TableCell cell1 = (e.Item as GridFilteringItem)["CreatededDate"];
}
}
aspx page code block:
<
telerik:GridBoundColumn
DataField
=
"CreatedDate"
DataFormatString
=
"{0:MM/dd/yyyy}"
HeaderText
=
"Created Date"
SortExpression
=
"CreatedDate"
UniqueName
=
"CreatedDate"
FilterControlWidth
=
"200px"
>
<
FilterTemplate
>
From <
telerik:RadDatePicker
ID
=
"FromDatePicker"
runat
=
"server"
Width
=
"85px"
ClientEvents-OnDateSelected
=
"FromDateSelected"
DbSelectedDate='<%# startDate %>' Calendar-FastNavigationStep="12" Calendar-RangeMinDate="1/1/1901 12:00:00 AM" />
<
br
/>
To <
telerik:RadDatePicker
ID
=
"ToDatePicker"
runat
=
"server"
Width
=
"85px"
ClientEvents-OnDateSelected
=
"ToDateSelected"
DbSelectedDate='<%# endDate %>' Calendar-FastNavigationStep="12" Calendar-RangeMinDate="1/1/1901 12:00:00 AM" />
<
telerik:RadScriptBlock
ID
=
"RadScriptBlock1"
runat
=
"server"
>
I figured out the isExported but I got null value for the two datapickers and how to replace the two datapicker controls with two dates?
Amy
0

Amy Liu
Top achievements
Rank 1
answered on 27 Oct 2011, 08:49 PM
protected void rgSearchResults_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridFilteringItem && isExported)
{
DateTime? fromDate=null;
DateTime? toDate = null;
RadDatePicker fromControl = e.Item.FindControl("FromDatePicker") as RadDatePicker;
RadDatePicker toControl = e.Item.FindControl("ToDatePicker") as RadDatePicker;
fromDate = startDate; // fromControl.SelectedDate; //for some reason it return null value
toDate = endDate; // toControl.SelectedDate; //for some reason it return null value
TableCell cell = (e.Item as GridFilteringItem)["CreatedDate"];
//cell.Text = "01/01/2010" + " To " +"01/30/2010"; // toDate; //changed to get it from property value
cell.Text = startDate + " To " +endDate; // toDate;
//TableCell cell1 = (e.Item as GridFilteringItem)["CreatededDate"];
}
}
I solved it by using the startDate and endDate of the property value as the DBSelectedvalue and SelectedValue of dataPicker is null.
I don't know why even though you set up the viewstatemode=enabled.
I posted it here in case somebody need it.
boo isExported=false and
inside page_load: to set it up to true when exporttoexcel button clicked
string ctrlname = Request.Params.Get("__EVENTTARGET");
if (ctrlname != null && ctrlname != string.Empty)
{
if (ctrlname.Contains("ExportToExcelButton"))
isExported =
true;
}