ekondur / DatatableJS

Jquery datatable with entity framework using MVC html helper
MIT License
36 stars 15 forks source link

Sub properties for complex data item classes #121

Closed Alexplose closed 1 year ago

Alexplose commented 1 year ago

Tried to use complex class as data item, sub properties are set as ID only, and not Establishment.ID.

That works well for columns as soon as there is no name colision, but the filter part don't work.

Any tips how it can be achieved or should I switch to simple flat classes ?

@(Html.JS().Datatable<DashboardItemViewModel>() .Name("DashboardGrid") .Columns(col => { col.Field(a => a.Establishment.ID).Visible(false); col.Field(a => a.Establishment.Name).Class("text-danger"); col.Command(a => a.Establishment.ID,"","", "onClick", text: "Click").Title(""); }) .Filters(filter => { filter.Add(a => a.Establishment.ID).GreaterThanOrEqual(1); })

ekondur commented 1 year ago

Hi @Alexplose, Thank you for using this framework. Unfortunately, because of some performance concerns, DatatableJS does not support complex items. I suggest you create a new view model including only primitive types or strings for listing data.

Alexplose commented 1 year ago

Great thank you for your quick answer. Is it possible using the Html.JS() syntax to separate the generated Html parts and the script part? I'm loading js files at the very end of the body tag and it doesn't work with the builder.

ekondur commented 1 year ago

It is up to the project or developer @Alexplose Because we don't know which script versions are used and whether these scripts are internal or from CDN etc.