This is a migrated thread and some comments may be shown as answers.

Groups in Listview with OData

3 Answers 92 Views
ListView (Mobile)
This is a migrated thread and some comments may be shown as answers.
Per Lindsø
Top achievements
Rank 2
Per Lindsø asked on 22 Oct 2012, 01:04 PM
Hi,

how can I do client-side grouping for a mobile listview with Odata.

I have:
         ds = new kendo.data.DataSource({
                        type: "odata",
                        transport: {
                            read: {
                                url: "Servide.svc/kendotest"l,
                                dataType: "jsonp"
                            },
...
});

And I can populate the listview with:

 function mobileListViewTemplatesInit() {
        $("#custom-listview").kendoMobileListView({
            dataSource: ds,
....
});


But how do I group by one of the fields in the datasource?

Thanks in advance
Per

3 Answers, 1 is accepted

Sort by
0
Per Lindsø
Top achievements
Rank 2
answered on 22 Oct 2012, 09:23 PM
I found the answer. Add 
group: {field: "grouping_field"} 
to datasource.


0
Andrew
Top achievements
Rank 1
answered on 09 Nov 2012, 12:36 AM
What if the grouping field is a date? Should it be passed from the service as a date or a string? I find that when I pass it as a date javascript throws an error, but when I pass it as a string the sorting gets all screwy. Is there a way to tell the group to treat a string as a date for sorting purposes but to display it as the string/short date?


0
Andrew
Top achievements
Rank 1
answered on 09 Nov 2012, 01:36 AM
I worked around it. I just appended a date difference from the lowest date in my series to the date on the item

example:
0-10/7/2012
1-10/8/2012
2-10/9/2012

Then for the listview I set the headerTemplate as follows based on the sushi example. This worked because I'm only getting one week worth of dates at this point, so 6- will be the highest I have. I would have to write a little more logic if I was going to get into double digits.
$("#grouped-listview").kendoMobileListView({
    dataSource: dataSource,
    pullToRefresh: true,
    appendOnRefresh: false,
    template: $("#pull-to-refresh-template").text(),
    headerTemplate: "${value.substring(2,15)}",
    endlessScroll: true
});
Tags
ListView (Mobile)
Asked by
Per Lindsø
Top achievements
Rank 2
Answers by
Per Lindsø
Top achievements
Rank 2
Andrew
Top achievements
Rank 1
Share this question
or