Groups in Listview with OData

4 posts, 0 answers
  1. lindsoe
    lindsoe avatar
    21 posts
    Member since:
    Jul 2007

    Posted 22 Oct 2012 Link to this post

    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
  2. lindsoe
    lindsoe avatar
    21 posts
    Member since:
    Jul 2007

    Posted 22 Oct 2012 Link to this post

    I found the answer. Add 
    group: {field: "grouping_field"} 
    to datasource.


  3. Kendo UI is VS 2017 Ready
  4. Andrew
    Andrew avatar
    14 posts
    Member since:
    Nov 2010

    Posted 08 Nov 2012 Link to this post

    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?


  5. Andrew
    Andrew avatar
    14 posts
    Member since:
    Nov 2010

    Posted 08 Nov 2012 Link to this post

    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
    });
Back to Top
Kendo UI is VS 2017 Ready