How can I sort a list using the drag/drop sortorder

Nov 13, 2014 at 12:58 AM
Can I apply the same sort order as used in the "Edit List" to a list I filter? I find that the sort order is not the same. Our client wants to be able to use the drag and drop to change the sort order of the list items but also apply filtering.
Nov 13, 2014 at 6:03 AM
No the drag and drop is just for that module instance. If you reuse the data in a different way its not linked to that module instance anymore but to the whole collection

what you can do ( does require some extra work from client ) is add a new field sortorder(numeric) and each time after you filter a list you can then custom sort it on the added sortorder field
Developer
Nov 13, 2014 at 11:45 AM
This is not possible if you are working with the DataSource-Approach.

But what you can do, of course, is using LINQ to filter the List. Try something like this (not tested):
@{
    var filteredList = List.Where(e => e.Content.MyNumber < 5);
}

@foreach(var e in filteredList) {
    var Content = e.Content;
    <div>
        @Content.MyNumber
    </div>
}
"filteredList" will keep the sort order that the original List had.
Nov 13, 2014 at 2:20 PM
Thank you for your quick replies!
I know we could create a custom sort order field but the client does not like that approach as it is very tedious to change sortorder for items as you would need to go in and edit them individually etc. Would it be possible to implement our own drag and drop sorting function in a template? If we did this, is there a way to update the records through the javascript API or does that API only allow data retrieval?
Developer
Nov 13, 2014 at 7:45 PM
The current JavaScript API can only read data. But we're working on a JavaScript API that can create, update and delete entities (records) - we'll release a beta version soon. I will update this discussion as soon as it's released.