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.
Unfortunately, activation email could not send to your email. Please try again.

VB for grouping and summarising columns

Thread ID:

Created:

Updated:

Platform:

Replies:

132646 Sep 13,2017 03:41 PM Sep 18,2017 06:51 AM ASP.NET MVC 5
loading
Tags: Grid
Ross Woodward
Asked On September 13, 2017 03:41 PM

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     

Mani Sankar Durai [Syncfusion]
Replied On September 14, 2017 08:08 AM

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. 


Ross Woodward
Replied On September 14, 2017 08:17 AM

fantastic, thanks!

Ross 


Mani Sankar Durai [Syncfusion]
Replied On September 15, 2017 07:58 AM

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. 


Ross Woodward
Replied On September 15, 2017 09:42 AM

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)


Mani Sankar Durai [Syncfusion]
Replied On September 18, 2017 06:51 AM

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. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;