Hello experts,
I have an export button on my RadGrid but it's working bad...The idea was to export a specific collumn...After some changes at this moment when i click to export, my grid shows the list to export, instead of give me a .csv....Can you help?
aspx:
aspx.cs:
I have an export button on my RadGrid but it's working bad...The idea was to export a specific collumn...After some changes at this moment when i click to export, my grid shows the list to export, instead of give me a .csv....Can you help?
aspx:
<telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" Width="97%" enableajax="True" AllowFilteringByColumn="True" ShowFooter="True" Skin="Black" OnItemCommand="RadGrid1_ItemCommand" OnGridExporting="RadGrid1_GridExporting" AllowMultiRowSelection="True" OnItemDataBound="RadGrid1_ItemDataBound"> <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle> <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True" EnablePostBackOnRowClick="true"> <Selecting AllowRowSelect="True" /> </ClientSettings> <MasterTableView DataKeyNames="SequencialNumber" Width="100%" CommandItemSettings-ShowExportToCsvButton="True" CommandItemSettings-ShowAddNewRecordButton="false" CommandItemDisplay="Top"> <Columns> <telerik:GridBoundColumn DataField="SequencialNumber" HeaderText="SequencialNumber" UniqueName="SequencialNumber" SortExpression="SequencialNumber"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Priority" HeaderText="Priority" UniqueName="Priority" FilterControlAltText="Filter Priority column" SortExpression="Priority" DataType="System.Int32"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Process" HeaderText="Staging" UniqueName="Process" SortExpression="Process" FilterControlAltText="Filter Process column"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="SupplierCode" HeaderText="SupplierCode" UniqueName="SupplierCode" SortExpression="SupplierCode" FilterControlAltText="Filter SupplierCode column"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="MessageStatus" HeaderText="MessageStatus" UniqueName="MessageStatus" SortExpression="MessageStatus" FilterControlAltText="Filter MessageStatus column"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="DocumentType" HeaderText="DocumentType" UniqueName="DocumentType" FilterControlAltText="Filter DocumentType column" SortExpression="DocumentType"> </telerik:GridBoundColumn> <telerik:GridDateTimeColumn UniqueName="InvoiceCreationDate" DataField="InvoiceCreationDate" HeaderText="InvoiceCreationDate" FilterControlAltText="Filter InvoiceCreationDate column" SortExpression="InvoiceCreationDate"> <FilterTemplate> <telerik:RadDatePicker ID="RadDatePicker1" runat="server"> </telerik:RadDatePicker> </FilterTemplate> </telerik:GridDateTimeColumn> <telerik:GridBoundColumn DataField="SupplierVatNumber" FilterControlAltText="Filter SupplierVatNumber column" HeaderText="SupplierVatNumber" SortExpression="SupplierVatNumber" UniqueName="SupplierVatNumber"> </telerik:GridBoundColumn> </Columns> <ExpandCollapseColumn Visible="False"> <HeaderStyle Width="19px"></HeaderStyle> </ExpandCollapseColumn> <RowIndicatorColumn Visible="False"> <HeaderStyle Width="20px" /> </RowIndicatorColumn> </MasterTableView> <FilterMenu EnableImageSprites="False"> </FilterMenu> <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"> </HeaderContextMenu> </telerik:RadGrid>aspx.cs:
public partial class InvoicesScalingDefault : iConnect.Web.iConnect, IInvoicesScale { private InvoicesScalePresenter _presenter; public System.Collections.Generic.IList<Data.SapDocuments> SapDocuments { get; set; } protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { this._presenter.OnViewInitialized(); LoadData(); } this._presenter.OnViewLoaded(); } [CreateNew] public InvoicesScalePresenter Presenter { set { this._presenter = value; this._presenter.View = this; } } /// <summary> /// Carregar RadGrid1 com o objecto SapDocuments /// </summary> private void LoadData() { string user = Page.User.Identity.Name.Substring(Page.User.Identity.Name.IndexOf("\\") + 1); EscalonamentoFacturasEntities objectContx = new EscalonamentoFacturasEntities(); RadGrid1.DataSource = objectContx.ShowUnprocessedInvoices(user); //RadGrid1.DataBind(); } protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e) { if (e.CommandName == Telerik.Web.UI.RadGrid.ExportToCsvCommandName) { RadGrid1.MasterTableView.Columns.FindByUniqueName("SequencialNumber").Visible = true; RadGrid1.ExportSettings.IgnorePaging = true; int count = 0; foreach (GridColumn column in RadGrid1.Columns) { if (column.Visible) { if (count > 0) column.Visible = false; else count++; } } } } protected void RadGrid1_GridExporting(object sender, GridExportingArgs e) { e.ExportOutput = e.ExportOutput.Replace("\"\r\n\"", "\"\r\n\"'"); }