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

preventing the autogenerate columns from reordering themselves

1 Answer 51 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Sayle asked on 05 Jul 2012, 11:17 PM
I have a very wide RadGrid (the latest public release version) that I'm using as an export into Excel. I have the root query ordering the columns a certian way - the way the customers want the Excel output in... However, when I databind my RadGrid on the webpage, the columns are automatically reordered into alphabetical order!

How do I preventing the autogenerated columns from reordering themselvesinto alphabetical order?

<telerik:RadGrid ID="gridSellerData" runat="server" Width="100%" CellSpacing="0" CellPadding="0"
    PageSize="5000" EnableLinqExpressions="False" HeaderStyle-Wrap="false" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" Skin="Hay"
    OnItemDataBound="grid_ItemDataBound" OnNeedDataSource="grid_NeedDataSource"
    OnPreRender="gridContractData_PreRender" OnGridExporting="gridSellerData_GridExporting"
    <ClientSettings AllowColumnsReorder="false">
        <Selecting EnableDragToSelectRows="false" UseClientSelectColumnOnly="false" />
        <Scrolling AllowScroll="true" UseStaticHeaders="true" FrozenColumnsCount="0" />
    <ExportSettings IgnorePaging="true" ExportOnlyData="true" Excel-Format="ExcelML" OpenInNewWindow="true" HideStructureColumns="true" />
    <MasterTableView CommandItemDisplay="Top" DataKeyNames="LoanImportID" ClientDataKeyNames="LoanImportID" GridLines="Both">
        <CommandItemSettings ExportToExcelText="Export To Excel" ShowExportToExcelButton="true" ShowAddNewRecordButton="false" ShowRefreshButton="false" />
        <ItemStyle CssClass="Row0" />
        <AlternatingItemStyle CssClass="Row1" />
    <HeaderStyle Wrap="False" />
    <FilterMenu EnableImageSprites="False">
    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Hay">

1 Answer, 1 is accepted

Sort by
Antonio Stoilkov
Telerik team
answered on 10 Jul 2012, 12:57 PM
Hello Miles,

The RadGrid does not provide methods and properties for customizing order of auto generated columns. You could achieve your scenario by using manually declared columns which you could order depending on your needs. Note that RadGrid auto generated columns are for basic scenarios and in case when more advanced functionality is needed a manual approach is recommended.

Kind regards,
Antonio Stoilkov
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.
Asked by
Top achievements
Rank 1
Answers by
Antonio Stoilkov
Telerik team
Share this question