[SailfishDevel] ListModel sorting in QML

Andrey Kozhevnikov coderusinbox at gmail.com
Sun Nov 17 13:05:39 UTC 2013


afaik the use of JSONListModel not intended the sorting functions.
you need to make own model and sort json data before pushing it to model.

On 17.11.2013 18:39, Tigre-Bleu wrote:
> Hi,
>
> I have a ListView which loads a model from JSON with JSONListModel. The model contains items and category ids, but is not sorted by category.
>
> What I wand to do is to display the items sorted by categories in the ListView. I have put a section.property in the ListView but it is working only half as expected because it is not sorting the model.
>
> For instance, if my model content is:
>
> Item1 - Category1
> Item2 - Category1
> Item3 - Category2
> Item4 - Category3
> Item5 - Category3
> Item6 - Category1
>
> Then my ListView will display:
>
> Category1
>    Item1
>    Item2
> Category2
>    Item3
> Category3
>    Item4
>    Item5
> Category1
>    Item6
>
> Of course I would like Item6 to be set between Item2 and Item3.
>
> How is possible to do that in QML? I would like to avoid manually iterating on all the items to re-order.
>
> Thanks,
>
> Antoine
> _______________________________________________
> SailfishOS.org Devel mailing list



More information about the Devel mailing list