ReflectionIT.Mvc.Paging icon indicating copy to clipboard operation
ReflectionIT.Mvc.Paging copied to clipboard

SortableHeaderFor custom Model

Open mdmota opened this issue 6 years ago • 5 comments

Describe the bug My page contain @model CustomModel: @model Test.Web.Models.CustomModel

CustomModel contain property PagingList: public ReflectionIT.Mvc.Paging.PagingList<MyType> MyList{ get; set; }

How i use SortableHeaderFor for columns from MyList from CustomModel? @Html.SortableHeaderFor(model => model.MyList.NameColumn) ** Dont work

mdmota avatar Apr 01 '19 14:04 mdmota

@sonnemaf

mdmota avatar May 22 '19 16:05 mdmota

Have you looked at this sample: https://github.com/sonnemaf/ReflectionIT.Mvc.Paging/blob/master/src/SampleApp/Views/Products/Index.cshtml ?

I think you need to use the extra overload in which you specify the sort string.

@Html.SortableHeaderFor(model => model.MyList.NameColumn, "MyList.NameColumn")

sonnemaf avatar May 23 '19 07:05 sonnemaf

Any further followups here? I am trying to do the exact same thing as the OP and can't get access to the SortableHeaderFor...everything else is looking fine.

thereelaristotle avatar Apr 21 '20 21:04 thereelaristotle

What I ultimately ended up doing was creating a class called ExtendedPagingList<T>...then building an additional Helper method to work with any models that derive from ExtendedPagingList<T>.

It works the only thing is that it cannot infer the type of the elements in the PagingList....so you need to specify them in the function call to SortableHeaderFor, might be a way around this but after like 5 hours I don't care to dig.

thereelaristotle avatar Apr 22 '20 14:04 thereelaristotle

Can you create a project for this problem and publish it in a public github repository? I will have a look at it. Don't have time to create one myself.

sonnemaf avatar Apr 22 '20 18:04 sonnemaf