ekondur/DatatableJS

Sub properties for complex data item classes

Closed this issue · 3 comments

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); })

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.

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.

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.