Hello Friends,
I have one page in that i created dynamically bound column and bind it to radgrid.
I need to apply grouping dynamically.
When i try to apply grouping than i got the below error.jpg(attachment) error.
Below is my .aspx code
<radG:RadGrid ID="dgVendorLists" runat="server" AllowSorting="True" AllowPaging="true"
GroupPanel-Text="Drag and Drop Column Header To Regroup Column. " EnableAJAX="False"
AllowFilteringByColumn="True" ShowGroupPanel="True" ExportSettings-ExportOnlyData="true"
ExportSettings-IgnorePaging="true" ExportSettings-OpenInNewWindow="true" ShowFooter="false"
Skin="Monochrome" BorderStyle="None" MasterTableView-CellPadding="0" EnableAJAXLoadingTemplate="False"
GridLines="both" ClientSettings-ApplyStylesOnClient="true" Width="100%" PageSize="19" GroupingEnabled="true">
<PagerStyle Mode="NumericPages" />
<MasterTableView AutoGenerateColumns="False" CommandItemDisplay="None" GroupLoadMode="Server"
EnableColumnsViewState="true" TableLayout="Fixed">
<ExpandCollapseColumn Visible="False">
<HeaderStyle Width="19px" />
</ExpandCollapseColumn>
<RowIndicatorColumn Visible="False">
<HeaderStyle Width="20px" />
</RowIndicatorColumn>
<Columns>
</Columns>
</MasterTableView>
<ClientSettings EnableClientKeyValues="True" ReorderColumnsOnClient="True" AllowColumnsReorder="True"
AllowGroupExpandCollapse="True" AllowDragToGroup="True">
<Resizing AllowColumnResize="True" EnableRealTimeResize="True" ResizeGridOnColumnResize="False" />
<Selecting AllowRowSelect="true" />
<Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True" ScrollHeight="405px">
</Scrolling>
</ClientSettings>
<PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true"></PagerStyle>
</radG:RadGrid>
Below is my .vb code.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
CreateTempUserTable()
End If
End Sub
Private Sub CreateTempUserTable()
ViewState("dtUser") = Nothing
Dim dt As New DataTable
dt.Columns.Add("name")
dt.Columns.Add("Companyid")
Dim dr As DataRow
Dim i As Integer
For i = 0 To 10
dr = dt.NewRow()
dr("name") = "Test" & i
If i = 0 Or i = 2 Or i = 4 Or i = 8 Then
dr("Companyid") = "10"
Else
dr("Companyid") = "20"
End If
dt.Rows.Add(dr)
Next
Dim boundName As New GridBoundColumn
boundName.AllowFiltering = True
boundName.DataField = "name"
boundName.HeaderText = "name"
boundName.HeaderText = "name"
boundName.GroupByExpression = "name"
boundName.Groupable = True
dgVendorLists.MasterTableView.Columns.Add(boundName)
Dim boundCompanyId As New GridBoundColumn
boundCompanyId.AllowFiltering = True
boundCompanyId.DataField = "Companyid"
boundCompanyId.HeaderText = "Companyid"
boundCompanyId.UniqueName = "Companyid"
boundCompanyId.SortExpression = "Companyid"
boundCompanyId.Display = True
boundCompanyId.Groupable = True
boundCompanyId.GroupByExpression = "Companyid"
dgVendorLists.MasterTableView.Columns.Add(boundCompanyId)
dgVendorLists.DataSource = dt
dgVendorLists.DataBind()
ViewState("dt") = dt
End Sub
Protected Sub dgVendorLists_NeedDataSource(ByVal source As Object, ByVal e As Telerik.WebControls.GridNeedDataSourceEventArgs) Handles dgVendorLists.NeedDataSource
Me.dgVendorLists.DataSource = ViewState("dt")
End Sub
Protected Sub dgVendorLists_Grouping(ByVal source As Object, ByVal e As Telerik.WebControls.GridGroupsChangingEventArgs) Handles dgVendorLists.GroupsChanging
Dim expression As GridGroupByExpression = New GridGroupByExpression
Dim gridGroupByField As GridGroupByField = New GridGroupByField
gridGroupByField = New GridGroupByField
gridGroupByField.FieldName = "Companyid"
expression.GroupByFields.Add(gridGroupByField)
dgVendorLists.MasterTableView.GroupByExpressions.Add(expression)
dgVendorLists.Rebind()
End Sub
Please help me where i am wrong and how to implement grouping dynamically with dynamic column.
Thanks & Regards
Jignesh Patel
I have one page in that i created dynamically bound column and bind it to radgrid.
I need to apply grouping dynamically.
When i try to apply grouping than i got the below error.jpg(attachment) error.
Below is my .aspx code
<radG:RadGrid ID="dgVendorLists" runat="server" AllowSorting="True" AllowPaging="true"
GroupPanel-Text="Drag and Drop Column Header To Regroup Column. " EnableAJAX="False"
AllowFilteringByColumn="True" ShowGroupPanel="True" ExportSettings-ExportOnlyData="true"
ExportSettings-IgnorePaging="true" ExportSettings-OpenInNewWindow="true" ShowFooter="false"
Skin="Monochrome" BorderStyle="None" MasterTableView-CellPadding="0" EnableAJAXLoadingTemplate="False"
GridLines="both" ClientSettings-ApplyStylesOnClient="true" Width="100%" PageSize="19" GroupingEnabled="true">
<PagerStyle Mode="NumericPages" />
<MasterTableView AutoGenerateColumns="False" CommandItemDisplay="None" GroupLoadMode="Server"
EnableColumnsViewState="true" TableLayout="Fixed">
<ExpandCollapseColumn Visible="False">
<HeaderStyle Width="19px" />
</ExpandCollapseColumn>
<RowIndicatorColumn Visible="False">
<HeaderStyle Width="20px" />
</RowIndicatorColumn>
<Columns>
</Columns>
</MasterTableView>
<ClientSettings EnableClientKeyValues="True" ReorderColumnsOnClient="True" AllowColumnsReorder="True"
AllowGroupExpandCollapse="True" AllowDragToGroup="True">
<Resizing AllowColumnResize="True" EnableRealTimeResize="True" ResizeGridOnColumnResize="False" />
<Selecting AllowRowSelect="true" />
<Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True" ScrollHeight="405px">
</Scrolling>
</ClientSettings>
<PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true"></PagerStyle>
</radG:RadGrid>
Below is my .vb code.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
CreateTempUserTable()
End If
End Sub
Private Sub CreateTempUserTable()
ViewState("dtUser") = Nothing
Dim dt As New DataTable
dt.Columns.Add("name")
dt.Columns.Add("Companyid")
Dim dr As DataRow
Dim i As Integer
For i = 0 To 10
dr = dt.NewRow()
dr("name") = "Test" & i
If i = 0 Or i = 2 Or i = 4 Or i = 8 Then
dr("Companyid") = "10"
Else
dr("Companyid") = "20"
End If
dt.Rows.Add(dr)
Next
Dim boundName As New GridBoundColumn
boundName.AllowFiltering = True
boundName.DataField = "name"
boundName.HeaderText = "name"
boundName.HeaderText = "name"
boundName.GroupByExpression = "name"
boundName.Groupable = True
dgVendorLists.MasterTableView.Columns.Add(boundName)
Dim boundCompanyId As New GridBoundColumn
boundCompanyId.AllowFiltering = True
boundCompanyId.DataField = "Companyid"
boundCompanyId.HeaderText = "Companyid"
boundCompanyId.UniqueName = "Companyid"
boundCompanyId.SortExpression = "Companyid"
boundCompanyId.Display = True
boundCompanyId.Groupable = True
boundCompanyId.GroupByExpression = "Companyid"
dgVendorLists.MasterTableView.Columns.Add(boundCompanyId)
dgVendorLists.DataSource = dt
dgVendorLists.DataBind()
ViewState("dt") = dt
End Sub
Protected Sub dgVendorLists_NeedDataSource(ByVal source As Object, ByVal e As Telerik.WebControls.GridNeedDataSourceEventArgs) Handles dgVendorLists.NeedDataSource
Me.dgVendorLists.DataSource = ViewState("dt")
End Sub
Protected Sub dgVendorLists_Grouping(ByVal source As Object, ByVal e As Telerik.WebControls.GridGroupsChangingEventArgs) Handles dgVendorLists.GroupsChanging
Dim expression As GridGroupByExpression = New GridGroupByExpression
Dim gridGroupByField As GridGroupByField = New GridGroupByField
gridGroupByField = New GridGroupByField
gridGroupByField.FieldName = "Companyid"
expression.GroupByFields.Add(gridGroupByField)
dgVendorLists.MasterTableView.GroupByExpressions.Add(expression)
dgVendorLists.Rebind()
End Sub
Please help me where i am wrong and how to implement grouping dynamically with dynamic column.
Thanks & Regards
Jignesh Patel