We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

VB for grouping and summarising columns

Hi Folks, I'm really struggling to get my head around the syntax for this!

from the docs I've got the c# as 

.GroupSettings(group => { group.GroupedColumns(col => {
col.Add("ShipCountry"); col.Add("tncID"); }); })

but I can't work out the correct syntax for VB.

here's my code so far, which works and enables grouping but doesnt group by default, as you can see i've tried a couple of different versions!

my next challenge will be to get the equivalent of 

.SummaryRow(row =>
{
row.Title("Sum").SummaryColumns(col => {
col.SummaryType(SummaryType.Sum).Format("{0:C}").DisplayColumn("qtyCurrent").Da
taMember("qtyCurrent").Add(); }).Add();
})

if anyone can steer me in the right direction I'd really appreciate it!

        @code 

            Dim gridbuilder = Html.EJ().Grid(Of CustomerHistDb)("SampleGrid")
            gridbuilder.Datasource(ViewBag.CustomerHistdb)
            gridbuilder.Columns(
        Sub(col)
            col.Field("tncType").HeaderText("Type").Add()
            col.Field("tncID").HeaderText("tncID").Add()
            col.Field("tncAddress1").HeaderText("Address1").Add()
            col.Field("tncAddress2").HeaderText("Address2").Add()
            col.Field("tncPostcode").HeaderText("Postcode").Add()
            col.Field("tnccot").Add()
            col.Field("qtyCurrent").HeaderText("Current").add()
        End Sub)
            gridbuilder.AllowPaging()

            gridbuilder.AllowGrouping()

            Dim gs As New Syncfusion.JavaScript.Models.GroupSettings
            Dim gl As New List(Of String)
            gl.Add("tncID")
            gs.GroupedColumns.Add(gl.ToString)

            'gs.GroupedColumns = New List Of String from (Sub(col) col.field("tncid").Add())).tolist
            '        gridbuilder.GroupSettings(Sub(grp) grp.GroupedColumns(Sub(col) col.field("tncid").Add())))

            'gridbuilder.GroupSettings()
            'gs.ShowGroupedColumn = True

            gridbuilder.Render()

        End code     

5 Replies

MS Mani Sankar Durai Syncfusion Team September 14, 2017 12:08 PM UTC

Hi Ross, 

Thanks for contacting Syncfusion support. 

We have analyzed your query and found that you want to set the grouped columns and summary for the grid at the initial time in VB. We have prepared a sample based on your requirement that can be downloaded from the below link. 
Refer the code example 
   Dim gridbuilder = Html.EJ().Grid(Of Object)("SampleGrid") 
... 
        gridbuilder.AllowGrouping() 
        gridbuilder.GroupSettings(Sub(group) 
                                          group.GroupedColumns(Sub(col) col.Add("ShipCountry")) 
                                  End Sub) 
        gridbuilder.ShowSummary(). 
        SummaryRow(Sub(row) 
                           row.Title("Sum").SummaryColumns(Sub(col) col.SummaryType(SummaryType.Sum).Format("{0:C}").DisplayColumn("Freight").DataMember("Freight").Add()).Add() 
                           row.Title("Average").SummaryColumns(Sub(col) col.SummaryType(SummaryType.Average).Format("{0:C}").DisplayColumn("Freight").DataMember("Freight").Add()).Add() 
                       End Sub) 
        gridbuilder.Columns( 
            Sub(col) 
... 
               End Sub) 
        gridbuilder.Render() 

Please let us know if you need further assistance. 

Regards, 
Manisankar Durai. 



RW Ross Woodward September 14, 2017 12:17 PM UTC

fantastic, thanks!

Ross 



MS Mani Sankar Durai Syncfusion Team September 15, 2017 11:58 AM UTC

Hi Ross, 

We are happy to hear that your problem has been solved.  

Please let us know if you need further assistance. 

Regards, 
Manisankar Durai. 



RW Ross Woodward September 15, 2017 01:42 PM UTC

ok, sorry to be a pain - but one more question!

Multiple summaries.

I can add 2 rows with summaries, however what i really want is two CELLS showing their summary on 1 row. They'll both be 'summed' so thats fine, its how to add the second col I can't work out.

I'm guessing its the same technique as i'll need to add a 2nd grouping column too?

Ross 

gridbuilder.ShowSummary().

           SummaryRow(Sub(row)

 row.Title("Sum").SummaryColumns(Sub(col) col.SummaryType(SummaryType.Sum).Format("{0:C}").DisplayColumn("qty").DataMember("qty").Add()).Add()                          row.Title("Sum").SummaryColumns(Sub(col)col.SummaryType(SummaryType.Sum).Format({0:C}").DisplayColumn("future").DataMember("future").Add()).Add()

                     End Sub)



MS Mani Sankar Durai Syncfusion Team September 18, 2017 10:51 AM UTC

Hi Ross, 

Thanks for contacting Syncfusion support. 

We have checked your query and found that you would like to summary for two columns under the same row (multiple summary on same row) in grid and also with multiple grouping. Based on your requirement we have prepared a sample that can be downloaded from the below link. 
Refer the code example 
@Code 
        Dim gridbuilder = Html.EJ().Grid(Of Object)("SampleGrid") 
... 
        gridbuilder.GroupSettings(Sub(group) 
                                          group.GroupedColumns(Sub(col) col.Add("ShipCountry")) 
                                          group.GroupedColumns(Sub(col) col.Add("EmployeeID"))        //multiple grouped column 
                                  End Sub) 
        gridbuilder.ShowSummary(). 
        SummaryRow(Sub(row) 
                           row.Title("Sum").SummaryColumns(Sub(col) col.SummaryType(SummaryType.Sum).Format("{0:C}").DisplayColumn("Freight").DataMember("Freight").Add()).SummaryColumns(Sub(col) col.SummaryType(SummaryType.Sum).DisplayColumn("EmployeeID").DataMember("EmployeeID").Add()).Add()   //enable multiple summary columns under the same summary row 
                           row.Title("Average").SummaryColumns(Sub(col) col.SummaryType(SummaryType.Average).Format("{0:C}").DisplayColumn("Freight").DataMember("Freight").Add()).Add() 
                   End Sub) 
        gridbuilder.Columns( 
            Sub(col) 
                ... 
               End Sub) 
        gridbuilder.Render() 
    End Code 


Please let us know if you need further assistance. 

Regards, 
Manisankar Durai. 


Loader.
Live Chat Icon For mobile
Up arrow icon