
John Chatt
Top achievements
Rank 1
John Chatt
asked on 12 Apr 2010, 04:18 PM
I have a RadGrid controlled by the RadComboBox inside the CommandItemTemplate. The combobox controls what data are displayed inside the RadGrid. It works fine most of the time but when the current data are sorted the RadGrid won't rebind because it will still try to sort by the sortingColumn of the previous data set, which doesn't exist in the new one.
How can I clear the sort value so I can get my RadGrid to rebind?
How can I clear the sort value so I can get my RadGrid to rebind?
7 Answers, 1 is accepted
0
Hello John,
I tried to replicate the issue you are facing on the online demo below, but unfortunately to no avail.
Grid Filtered by Combo
Could you please elaborate what is the difference in your scenario?
Regards,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
I tried to replicate the issue you are facing on the online demo below, but unfortunately to no avail.
Grid Filtered by Combo
Could you please elaborate what is the difference in your scenario?
Regards,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0

John Chatt
Top achievements
Rank 1
answered on 13 Apr 2010, 03:38 PM
One of the major differences between my code and your example is that the radgrid changes completely. All columns are different for each potential ComboBox value. The second major difference is that in my code the ComboBox is autopostback and the pages OnLoad event clears all SqlDataSource parameters and repopulates the SqlDataSource based on which value is selected in the ComboBox. It will then databind the SqlDataSource and rebind the MasterTableView.
<rad:RadGrid ID="rgCodeTables" runat="server" AllowPaging="True" AllowAutomaticInserts="true"
AllowSorting="True" AllowAutomaticUpdates="true" AllowAutomaticDeletes="true"
DataSourceID="sdsCodeTables" GridLines="None" PageSize="15"
MasterTableView-EditMode="InPlace" OnDataBound="rgCodeTables_DataBound"
OnItemUpdated="rgCodeTables_OnItemUpdated" OnItemInserted="rgCodeTables_OnItemInserted">
<ExportSettings ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true">
<Excel FileExtension="xls" Format="ExcelML" />
<Pdf Author='<%= String.Format("PowerDMS - {0}", PowerDMSSession.SiteName) %>' />
</ExportSettings>
<MasterTableView AutoGenerateColumns="False" DataSourceID="sdsCodeTables"
CommandItemDisplay="Top" PagerStyle-AlwaysVisible="true"
InsertItemDisplay="Top" InsertItemPageIndexAction="ShowItemOnCurrentPage">
<RowIndicatorColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<CommandItemTemplate>
<div style="padding:2px 5px 3px; position:relative;">
<div style="float:left; width:30%;">
<asp:LinkButton ID="lbInsert" runat="server" CommandName="InitInsert"
Visible='<%# !rgCodeTables.MasterTableView.IsItemInserted %>' style="display:inline-block;
background:url('../ui/images/AddRecord.gif') no-repeat left 2px; padding:2px 0px 2px 20px; margin:2px 0 0;">
Add new
</asp:LinkButton>
<asp:LinkButton ID="btnCancel" runat="server" CommandName="CancelAll"
Visible='<%# rgCodeTables.EditIndexes.Count > 0 || rgCodeTables.MasterTableView.IsItemInserted %>'>
<img style="border:0px;vertical-align:middle;" alt="" src="../ui/images/Cancel.gif" />
<span style="padding:1px 0 0 3px; vertical-align:middle;">Cancel editing</span>
</asp:LinkButton>
</div>
<div style="float:left; text-align:center; width:40%; padding-top:2px;">
<rad:RadComboBox ID="rcbCodeTables" runat="server" AutoPostBack="true">
<Items>
<rad:RadComboBoxItem Text="Locations" Value="Locations" />
<rad:RadComboBoxItem Text="Job Titles" Value="JobTitles" />
<rad:RadComboBoxItem Text="Phone Types" Value="PhoneTypes" />
<rad:RadComboBoxItem Text="Document Types" Value="DocumentTypes" />
<rad:RadComboBoxItem Text="Course Types" Value="CourseTypes" />
<rad:RadComboBoxItem Text="Certificate Types" Value="CertificateTypes" />
<rad:RadComboBoxItem Text="Fee Types" Value="FeeTypes" />
</Items>
</rad:RadComboBox>
</div>
<div style="float:right; width:30%; text-align:right; margin-top:0px;">
<asp:LinkButton ID="lbRefresh" runat="server" CommandName="RebindGrid"
style="display:inline-block; background:url('../ui/images/Refresh.gif') no-repeat left 6px;
padding:5px 0px 0px 20px;" >
Refresh
</asp:LinkButton>
|
<asp:LinkButton ID="lbExportToExcel" runat="server" CommandName="ExportToExcel" style="display:inline-block; height:20px;">
<img style="border:0px;" alt="" src="../ui/images/page_white_excel.png" />
</asp:LinkButton>
<asp:LinkButton ID="lbExportToPdf" runat="server" CommandName="ExportToPdf" style="display:inline-block; height:20px;">
<img style="border:0px;" alt="" src="../ui/images/doc_pdf.png" />
</asp:LinkButton>
<asp:LinkButton ID="lbExportToWord" runat="server" CommandName="ExportToWord" style="display:inline-block; height:20px;">
<img style="border:0px;" alt="" src="../ui/images/page_white_word.png" />
</asp:LinkButton>
</div>
<div style="clear:both;"></div>
</div>
</CommandItemTemplate>
</MasterTableView>
</rad:RadGrid>
pseudo-code of codebehind
OnLoad(){
sdsCodeTables.ConnectionString = DatabaseUtility.GetPowerDMSConnectionString();
ClearDataSourceParameters();
{ Populate sdsCodeTables with Data }
{ Set new rgCodeTables.MasterTableView.DataKeyNames }
sdsCodeTables.DataBind();
rgCodeTables.CurrentPageIndex = 0;
rgCodeTables.MasterTableView.Rebind();
}
I still have no idea how to fix this. Is there no way to clear the radGrid's "sort by" value?
<rad:RadGrid ID="rgCodeTables" runat="server" AllowPaging="True" AllowAutomaticInserts="true"
AllowSorting="True" AllowAutomaticUpdates="true" AllowAutomaticDeletes="true"
DataSourceID="sdsCodeTables" GridLines="None" PageSize="15"
MasterTableView-EditMode="InPlace" OnDataBound="rgCodeTables_DataBound"
OnItemUpdated="rgCodeTables_OnItemUpdated" OnItemInserted="rgCodeTables_OnItemInserted">
<ExportSettings ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true">
<Excel FileExtension="xls" Format="ExcelML" />
<Pdf Author='<%= String.Format("PowerDMS - {0}", PowerDMSSession.SiteName) %>' />
</ExportSettings>
<MasterTableView AutoGenerateColumns="False" DataSourceID="sdsCodeTables"
CommandItemDisplay="Top" PagerStyle-AlwaysVisible="true"
InsertItemDisplay="Top" InsertItemPageIndexAction="ShowItemOnCurrentPage">
<RowIndicatorColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<CommandItemTemplate>
<div style="padding:2px 5px 3px; position:relative;">
<div style="float:left; width:30%;">
<asp:LinkButton ID="lbInsert" runat="server" CommandName="InitInsert"
Visible='<%# !rgCodeTables.MasterTableView.IsItemInserted %>' style="display:inline-block;
background:url('../ui/images/AddRecord.gif') no-repeat left 2px; padding:2px 0px 2px 20px; margin:2px 0 0;">
Add new
</asp:LinkButton>
<asp:LinkButton ID="btnCancel" runat="server" CommandName="CancelAll"
Visible='<%# rgCodeTables.EditIndexes.Count > 0 || rgCodeTables.MasterTableView.IsItemInserted %>'>
<img style="border:0px;vertical-align:middle;" alt="" src="../ui/images/Cancel.gif" />
<span style="padding:1px 0 0 3px; vertical-align:middle;">Cancel editing</span>
</asp:LinkButton>
</div>
<div style="float:left; text-align:center; width:40%; padding-top:2px;">
<rad:RadComboBox ID="rcbCodeTables" runat="server" AutoPostBack="true">
<Items>
<rad:RadComboBoxItem Text="Locations" Value="Locations" />
<rad:RadComboBoxItem Text="Job Titles" Value="JobTitles" />
<rad:RadComboBoxItem Text="Phone Types" Value="PhoneTypes" />
<rad:RadComboBoxItem Text="Document Types" Value="DocumentTypes" />
<rad:RadComboBoxItem Text="Course Types" Value="CourseTypes" />
<rad:RadComboBoxItem Text="Certificate Types" Value="CertificateTypes" />
<rad:RadComboBoxItem Text="Fee Types" Value="FeeTypes" />
</Items>
</rad:RadComboBox>
</div>
<div style="float:right; width:30%; text-align:right; margin-top:0px;">
<asp:LinkButton ID="lbRefresh" runat="server" CommandName="RebindGrid"
style="display:inline-block; background:url('../ui/images/Refresh.gif') no-repeat left 6px;
padding:5px 0px 0px 20px;" >
Refresh
</asp:LinkButton>
|
<asp:LinkButton ID="lbExportToExcel" runat="server" CommandName="ExportToExcel" style="display:inline-block; height:20px;">
<img style="border:0px;" alt="" src="../ui/images/page_white_excel.png" />
</asp:LinkButton>
<asp:LinkButton ID="lbExportToPdf" runat="server" CommandName="ExportToPdf" style="display:inline-block; height:20px;">
<img style="border:0px;" alt="" src="../ui/images/doc_pdf.png" />
</asp:LinkButton>
<asp:LinkButton ID="lbExportToWord" runat="server" CommandName="ExportToWord" style="display:inline-block; height:20px;">
<img style="border:0px;" alt="" src="../ui/images/page_white_word.png" />
</asp:LinkButton>
</div>
<div style="clear:both;"></div>
</div>
</CommandItemTemplate>
</MasterTableView>
</rad:RadGrid>
pseudo-code of codebehind
OnLoad(){
sdsCodeTables.ConnectionString = DatabaseUtility.GetPowerDMSConnectionString();
ClearDataSourceParameters();
{ Populate sdsCodeTables with Data }
{ Set new rgCodeTables.MasterTableView.DataKeyNames }
sdsCodeTables.DataBind();
rgCodeTables.CurrentPageIndex = 0;
rgCodeTables.MasterTableView.Rebind();
}
I still have no idea how to fix this. Is there no way to clear the radGrid's "sort by" value?
0
Hello John,
Resetting the datasource of the control at any stage of the page lifecycle is not a good practice. After you are using DataSourceControl, you can call the Rebind method for the grid, which would ensure that the most recent data would be fetched. Additionally, if you would like to alter the records shown in the grid, you can still call the Rebind method, and simply alter the select statement which would fetch the data for the control.
Kind regards,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Resetting the datasource of the control at any stage of the page lifecycle is not a good practice. After you are using DataSourceControl, you can call the Rebind method for the grid, which would ensure that the most recent data would be fetched. Additionally, if you would like to alter the records shown in the grid, you can still call the Rebind method, and simply alter the select statement which would fetch the data for the control.
Kind regards,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0

John Chatt
Top achievements
Rank 1
answered on 14 Apr 2010, 07:18 PM
Thats exactly what I am doing. I am altering the select statement of the SqlDataSource and then rebinding the grid.
That doesn't work however because the grid is still trying to sort by a column that it is no longer receiving.
I need to clear the value the grid is trying to sort by. Is there no way to do this?
The telerik control seems to lack this functionality.
0
Hi John,
In order to find a quick solution/fix of this matter I will ask you to open a formal support ticket and send me a simple runnable application. Thus I could do all my best to help you in further in resolving this issue.
Sincerely yours,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
In order to find a quick solution/fix of this matter I will ask you to open a formal support ticket and send me a simple runnable application. Thus I could do all my best to help you in further in resolving this issue.
Sincerely yours,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0

Arumugasamy Janarthanan
Top achievements
Rank 1
answered on 23 Dec 2010, 11:40 PM
Hi,
I am having the same issue. Did you find a solution for this issue?
Regards,
Jana
I am having the same issue. Did you find a solution for this issue?
Regards,
Jana
0
Hello John,
We were not able to replicate the issue on our end. Can you share a bit more information on your specific case or send us a code we can test in order to observe the problem?
Regards,
Iana
the Telerik team
We were not able to replicate the issue on our end. Can you share a bit more information on your specific case or send us a code we can test in order to observe the problem?
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.