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
close icon

MVC 3 + Grid Builder + Hierarchical Grid = ?

I'm try to figure out how to add the hierarchical grid functionality to our project. The only example available build the grid in the view. Right now we configure the grid via the "GridPropertiesModel". The ".ChildGrid" in the view model seems to be expecting a string. That doesn't seem right to me.

Can you provide an example for us?


5 Replies

RR Ranjithkumar R G Syncfusion Team July 7, 2011 10:11 AM UTC

Hi Greg,

Thanks for using Syncfusion products.

Sorry for the delay in getting back to you.

We suggest you to use Hierarchical grid using GridBuilder i.e. in Viewpage. Hierarchical Grid is mainly designed to use in Viewpage. In GridPropertyModel, the child grid which expects string and the grid is rendered through which is not recommended.

Please let us know if you have any concern.

Regards,
Ranjithkumar.




GC Greg Clouston July 7, 2011 05:32 PM UTC

Ok, good to know.

My next question is how do I implement the child grid in a MVC 3 project using VB.Net?

I've attached a project containing my attempt to translate one of your examples. I can't seem to get it to work. Can you perhaps shed some light on what I'm doing wrong?



Hierarchical Grid 01_714c4b59.zip


RR Ranjithkumar R G Syncfusion Team July 13, 2011 11:01 AM UTC

Hi Greg,

Thanks for using Syncfusion products.

we suggest you to map the child grid using key value with the ColumnName. Then, we suggest you to add the child grid as template with the parent grid. Please refer to the code-snippets below.

[ASPX]



//adding childgrid

Dim gridChildBuilder = Html.Syncfusion().Grid(Of MvcApplication2.Order_Detail)("ChildGridAction_${OrderID}")

'add grid columns using gridChildBuilder
gridChildBuilder.Column(Function(cols) cols.Add(Of Integer)(Function(c As MvcApplication2.Order_Detail) c.ProductID).HeaderText("ProductID"))
gridChildBuilder.Column(Function(cols) cols.Add(Of Integer)(Function(c As MvcApplication2.Order_Detail) c.OrderID).HeaderText("OrderID"))
gridChildBuilder.Column(Function(cols) cols.Add(Of Integer)(Function(c As MvcApplication2.Order_Detail) c.UnitPrice).HeaderText("UnitPrice"))
gridChildBuilder.Column(Function(cols) cols.Add(Of Integer)(Function(c As MvcApplication2.Order_Detail) c.Quantity).HeaderText("Quantity"))
gridChildBuilder.Column(Function(cols) cols.Add(Of Integer)(Function(c As MvcApplication2.Order_Detail) c.Discount).HeaderText("Discount"))

gridChildBuilder.EnablePaging()
gridChildBuilder.EnableGrouping()
gridChildBuilder.EnableSorting()
gridChildBuilder.Mappers(Function(map) _
map.Action("ChildGridAction", New With { _
Key .OrderID = "${OrderID}" _
}))

Dim template = gridChildBuilder.ToChildGridTemplate()





//adding child grid as a template



gridbuilder.ChildGrid(Function(ChildGrid)

ChildGrid.ChildGridTemplate(template)

End Function _
)




[CodeBehind-CS]



_
Function ChildGridAction(ByVal args As PagingParams, ByVal OrderID As Integer) As ActionResult

Dim data As IEnumerable = New NorthwindDataContext().Order_Details.Where(Function(c) c.OrderID = OrderID).ToList()
Dim engine = TryCast(data.GridActions(Of Order_Detail)(), GridHtmlActionResult(Of Order_Detail))

Return engine
End Function



Please refer to the below link to download the modified sample.

Razor sample:

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=MvcApplication2-620874601.zip


ASPX sample:

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=Grouping-1222922153.zip



Please let me know if you have any queries.

Regards,
Ranjithkumar.




AR arif April 9, 2018 02:35 AM UTC

Thanks, For informations and books.


IR Isuriya Rajan Syncfusion Team April 9, 2018 04:38 AM UTC

Hi Greg, 

Thanks for the update, 

please let us know whether u need any other assistance 


Regards, 
Isuriya R 


Loader.
Live Chat Icon For mobile
Up arrow icon