Hello Everyone,
I have a RadGrid that uses GroupByExpressions. I'm setting the datasource via the NeedDataSource event. On the initial load everything loads fine and the data is displayed as expected. Any postback that causes the data to refresh via the .Rebind() method causes the grid to lose all data. When I remove the GroupByExpressions from the markup the grid works as expected. I've created a simplified version with the markup and code necessary to reproduce. We're running version 2011.3.1305.40. Does anyone have any ideas on how to fix this? Thanks.
Here is the markup:
Here is the code behind:
I have a RadGrid that uses GroupByExpressions. I'm setting the datasource via the NeedDataSource event. On the initial load everything loads fine and the data is displayed as expected. Any postback that causes the data to refresh via the .Rebind() method causes the grid to lose all data. When I remove the GroupByExpressions from the markup the grid works as expected. I've created a simplified version with the markup and code necessary to reproduce. We're running version 2011.3.1305.40. Does anyone have any ideas on how to fix this? Thanks.
Here is the markup:
<telerik:RadScriptManager runat="server" ID="ScriptManager1"></telerik:RadScriptManager> <telerik:RadGrid runat="server" ID="grdServices" AutoGenerateColumns="false" Width="300px" Height="650px" onneeddatasource="grdServices_NeedDataSource" onselectedindexchanged="grdServices_SelectedIndexChanged" > <MasterTableView DataKeyNames="ServiceId" NoMasterRecordsText="" NoDetailRecordsText="" Width="100%" TableLayout="Fixed" GridLines="None"> <GroupByExpressions> <telerik:GridGroupByExpression> <GroupByFields> <telerik:GridGroupByField FieldName="ServiceType" FieldAlias="Type" /> </GroupByFields> </telerik:GridGroupByExpression> </GroupByExpressions> <Columns> <telerik:GridBoundColumn DataField="ServiceId" Visible="false"></telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="ServiceType" Visible="false" ></telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Name" HeaderText="Service" ItemStyle-Wrap="false" ></telerik:GridBoundColumn> </Columns> </MasterTableView> <ClientSettings Selecting-AllowRowSelect="true" EnableRowHoverStyle="true" EnablePostBackOnRowClick="true" AllowGroupExpandCollapse="false" AllowDragToGroup="false"> <Scrolling AllowScroll="true" UseStaticHeaders="true" /> </ClientSettings> </telerik:RadGrid> <asp:Button ID="btnRefresh" runat="server" onclick="btnRefresh_Click" Text="Refresh" />
Here is the code behind:
protected void Page_Load(object sender, EventArgs e){}protected void grdServices_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e){ List<Service> Services = new List<Service>(); Services.Add(new Service() { ServiceId = 1, ServiceType = "My Service", Name = "srv 1" }); Services.Add(new Service() { ServiceId = 1, ServiceType = "My Service", Name = "srv 2" }); Services.Add(new Service() { ServiceId = 1, ServiceType = "My Service", Name = "srv 3" }); Services.Add(new Service() { ServiceId = 1, ServiceType = "Your Service", Name = "srv 4" }); Services.Add(new Service() { ServiceId = 1, ServiceType = "Your Service", Name = "srv 5" }); Services.Add(new Service() { ServiceId = 1, ServiceType = "Your Service", Name = "srv 6" }); grdServices.DataSource = Services;}protected void grdServices_SelectedIndexChanged(object sender, EventArgs e){}protected void btnRefresh_Click(object sender, EventArgs e){ grdServices.Rebind();}public class Service{ public int ServiceId { get; set; } public string ServiceType { get; set; } public string Name { get; set; }}