Translating to vb.net

I'm working on getting a grid working from this page: https://ej2.syncfusion.com/aspnetmvc/documentation/grid/getting-started-mvc/
I have the first minimal example working, and now I'm working on getting the columns to work, but I'm not sure how to write that part in visual basic.

Here's the C# code:

@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.DataSource).Columns(col =>
{
   col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
   col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add();
   col.Field("OrderDate").HeaderText("Order Date").Width("130").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Format("yMd").Add();
   col.Field("ShipCountry").HeaderText("Ship Country").Width("120").Add();

}).AllowPaging(true).AllowSorting(true).AllowFiltering(true).AllowGrouping(true).PageSettings(page => page.PageSize(5)).Render()


I don't need an example project, just an example snippet of the .Columns() bit.


2 Replies

JL jlwarranty June 21, 2021 09:25 PM UTC

Apparently it is like this:

.Columns(Function(col As Object) {
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(True).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(),
col.Field("
CustomerID").HeaderText("Customer Name").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(),

col.Field("OrderDate").HeaderText("Order Date").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(),
col.Field("ShipCountry").HeaderText("Ship Country").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Left).Add()
})



AG Ajith Govarthan Syncfusion Team June 22, 2021 05:06 PM UTC

Hi jlwarranty, 

Thanks for contacting Syncfusion support. 

Query: Translating to vb.net. 
 
Based on your query you are facing some issues in writing the columns snippet. So, before we procced to your query, please share the below details to validate further on your requirement. 

  1. Please let us know that do you want to write the columns definition in the vb .net?

  1. Do you want to iterate the columns to bind the columns dynamically in the Grid component?

  1. Do you want to write the columns alone in vb.net?
 
  1. What is the use case of writing the columns in vb.net?
 
Regards, 
Ajith G.  



Loader.
Up arrow icon