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

Grouping using code behind with vb.net

1 Answer 225 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 04 Nov 2014, 08:48 PM
I am trying to change grouping using code behind.   I have a radgrid which depending on what the user chooses group by one element or group by two.  I attempted to do this via the code below, however when I do this the radgrid never displays any records.  I have tried to add a DataSource and Databind before and after this code but the grid never displays any records.  If I hard code the grouping on the ASPX page the records will show up although I cannot change the grouping dynamically.   Can you tell me what I am doing wrong in the code below that records would not display?

        rgPhysician.MasterTableView.GroupByExpressions.Clear()
        Dim ShowFacilities As CheckBox = ctlOptions.FindControl("cbShowFacilities")
        If ShowFacilities.Checked Then
            Dim ge1 As New Telerik.Web.UI.GridGroupByExpression
            Dim gf1 As New Telerik.Web.UI.GridGroupByField
            gf1.FieldName = "Facility"
            gf1.HeaderValueSeparator = String.Empty
            gf1.HeaderText = "Facility - "
            ge1.SelectFields.Add(gf1)
            rgPhysician.MasterTableView.GroupByExpressions.Add(ge1)

            Dim ge2 As New Telerik.Web.UI.GridGroupByExpression
            Dim gf2 As New Telerik.Web.UI.GridGroupByField
            gf2.FieldName = "Name"
            gf2.HeaderValueSeparator = String.Empty
            gf2.HeaderText = " "
            ge2.SelectFields.Add(gf2)
            rgPhysician.MasterTableView.GroupByExpressions.Add(ge2)
        Else
            Dim ge2 As New Telerik.Web.UI.GridGroupByExpression
            Dim gf2 As New Telerik.Web.UI.GridGroupByField
            gf2.FieldName = "Name"
            gf2.HeaderValueSeparator = String.Empty
            gf2.HeaderText = " "
            ge2.SelectFields.Add(gf2)
            rgPhysician.MasterTableView.GroupByExpressions.Add(ge2)
        End If   





1 Answer, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 07 Nov 2014, 12:24 PM
Hello Patrick,

You need to add the GroupByField item in the GroupByFields collection as well. Please check out the following help article which elaborates more on this matter.

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Patrick
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Share this question
or