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

dynamically generated grid - sorting problems

3 Answers 157 Views
Grid
This is a migrated thread and some comments may be shown as answers.
TERRY
Top achievements
Rank 1
TERRY asked on 02 May 2011, 11:56 AM
In our website we have automatically generated grid. Basically on our .aspx we keep the radgrid declaration:

<telerik:RadGrid ID="rgAutoGrid" AllowSorting="true" DataSourceID="odsAuto"
                                runat="server" OnItemCreated="rgAutoGrid_ItemCreated" AllowPaging="true"
                                ShowFooter="true" AutoGenerateColumns="false" OnItemDataBound="rgAutoGrid_ItemDataBound" Skin="WebBlue" OnPageSizeChanged="Grid_SizeChanged"
                                OnSortCommand="rgAutoGrid_SortCommand">
                                <PagerStyle Mode="NextPrevAndNumeric" Position="TopAndBottom" AlwaysVisible="true" />
                            </telerik:RadGrid>

We populate that grid with columns inside odsAuto (ObjectDataSource)'s Selecting item. We discovered that we have to clear all the columns and add them again each time the selecting happens. If we won't do so then radgrid doesn't display data correctly - headers of grid have no captions and cell are either empty or contain "DataRowView" inside. Thanks to clearing and recreating columns inside Selecting event - paging for grid works. Unfortunately sorting fails. Data in cells are still displayed correctly in cells, but captions in headers disappear and there is no sorting applied to order inside grid. If you need any information - i'm willing to provide anything what's needed.

3 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 04 May 2011, 02:13 PM
Hi TERRY,

Please refer to the below topics for more information on how to define grid structure dynamically and how to change it on postback:
http://www.telerik.com/help/aspnet-ajax/grid-programmatic-creation.html
http://www.telerik.com/help/aspnet-ajax/grid-changing-structure-dynamically.html

Kind regards,
Iana
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
TERRY
Top achievements
Rank 1
answered on 09 May 2011, 12:39 PM
 I moved radgrid structure creation to Page_Load event. Unfortunately it didn't resolve my sorting problem and messed up paging. First page displays correctly - but after trying to get to the next page you'll see situation shown in the attachement. To make paging work correctly i have to clear all columns in the objectdatasource's selecting event and create whole radgrid structure at this point - not in page_load. When it comes to sorting - if i click on the column header to sort, all header captions disappear, i noticed also that column that before "sorting" had horizontal align set to "right" after performing sorting is loosting that setting (text gets left aligned). Order of rows doesn't change.
0
Iana Tsolova
Telerik team
answered on 10 May 2011, 03:49 PM
Hi TERRY,

Can you share the grid declaration and the server-side code for defining the grid structure?

All the best,
Iana
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
TERRY
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
TERRY
Top achievements
Rank 1
Share this question
or