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

RadGrid column sorting not working

2 Answers 158 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sekar
Top achievements
Rank 1
Sekar asked on 21 Aug 2008, 07:58 PM

Hi there,

I got a wierd problem on RadGrid when using inside a dynamically loaded (using LoadControl)  Usercontrol. the sorting not seems to work properly. I intially got this error

 $WebAnalytics$ReportViewer1$GeneralSummary1$rgGeneralSummary$ctl01$ctl02$ctl01$ctl03' could not be located or a different control is assigned to the same ID after postback. If the ID is not assigned, explicitly set the ID property of controls that raise postback events to avoid this error.

 
I am using the NeedDataSource to assign the datasource (without calling databind). Here is the declaration of the RadGrid.

<rad:RadGrid ID="rgGeneralSummary" runat="server" GridLines="None" AllowPaging="True"ShowStatusBar="true" PageSize="20" RadControlsDir="~/Resources/RadControls/" Skin="WebBlue" SkinID="WebBlue" SkinsPath="~/Resources/RadControls/Grid/Skins" AllowSorting="True" CellSpacing="10" CellPadding="5" AllowFilteringByColumn="false" ShowGroupPanel="True" Width="650px" AutoGenerateColumns="False" EnableAJAX="true" EnableAJAXLoadingTemplate="true" Height="250px" OnNeedDataSource="rgGeneralSummary_NeedDataSource">

<ClientSettings AllowDragToGroup="False">
<Scrolling AllowScroll="True" UseStaticHeaders="True" /></ClientSettings>

 <PagerStyle PagerTextFormat="&lt;strong&gt;{5} Records&lt;/strong&gt;. Change page: {4} &amp;nbsp;|&amp;nbsp; Displaying page {0} of {1}, items {2} to {3} of {5}." />

<MasterTableView AutoGenerateColumns="False" AllowFilteringByColumn="false" DataSourcePersistenceMode="ViewState"> 
<Columns>
<rad:GridBoundColumn DataField="Period" DataType="System.String" HeaderText="Period" SortExpression="Period" UniqueName="Period" ItemStyle-Width="130px" HeaderStyle-Width="130px">

 </rad:GridBoundColumn>
<rad:GridBoundColumn DataField="PageViews" DataType="System.Int32" HeaderText="PageViews"ItemStyle-Width="130px" HeaderStyle-Width="130px" ReadOnly="True" SortExpression="PageViews" UniqueName="PageViews">

 </rad:GridBoundColumn>

 <rad:GridBoundColumn DataField="Sessions" DataType="System.Int32" HeaderText="Sessions"ItemStyle-Width="130px" ReadOnly="True" HeaderStyle-Width="130px" SortExpression="Sessions" UniqueName="Sessions">

 </rad:GridBoundColumn>

 <rad:GridBoundColumn DataField="UniqueVisitors" DataType="System.Int32" HeaderText="Unique Visitors"

 ItemStyle-Width="130px" HeaderStyle-Width="130px" ReadOnly="True" SortExpression="UniqueVisitors" UniqueName="UniqueVisitors">

 </rad:GridBoundColumn>

 <rad:GridBoundColumn DataField="ViewsPerSession" DataType="System.Decimal" HeaderText="Page views per session" ItemStyle-Width="130px" HeaderStyle-Width="130px" ReadOnly="True" SortExpression="ViewsPerSession" UniqueName="ViewsPerSession">

 </rad:GridBoundColumn>

 </Columns>

 </MasterTableView>

 </rad:RadGrid>

Later i checked this post and introduced ItemCreated to set the Header links Id. This avoids the exception but issue still there. The sorting works fine in ascending order but the decending order is not working.

Please help me to fix this sorting issue.

2 Answers, 1 is accepted

Sort by
0
Leon
Top achievements
Rank 1
answered on 21 Aug 2008, 08:14 PM
Sekar,

Is there any other AJAX controls functioning in your scenario? Do you load that user control via some RadAjax control? If so, better disable the Grid AJAX mode and add dynamic AJAX setting (in case of RadAjaxManager) upon loading the control or wrap the container where the user control is loaded within RadAjaxPanel.

Changing the button ID sounds a bit .. hackish. There should be better solution for sure, so I hope you can avoid AJAX mess up if any thus getting this problem resolved.

Thanks,
~Leon
0
Sekar
Top achievements
Rank 1
answered on 26 Aug 2008, 11:43 PM
Hi Leon,
   I appreciate your response for my post. I do not use any Ajax functionality here, neither the RadAjaxManager. It's a usual postback scenario.
 
Let me know if you have any other catch on it.

Thanks
Tags
Grid
Asked by
Sekar
Top achievements
Rank 1
Answers by
Leon
Top achievements
Rank 1
Sekar
Top achievements
Rank 1
Share this question
or