Groupable grid using MVVM

2 posts, 1 answers
  1. eduardo
    eduardo  avatar
    8 posts
    Member since:
    Jul 2012

    Posted 18 Dec 2012 Link to this post

    Hello.
    I just updated to Kendo UI for ASP.NET MVC Q3 2012 and I am trying to create a pageable, filterable, sortable and groupable grid. We are using ASP.NET MVC, but because of the MVVC architecture we are using, the grid properties are being defined using html attributes, like this:

    <div id="userGrid"
      data-role="grid"
      data-columns='[{ "field": "Name", "title": "Name"}, { "field": "Group", "title": "Group"}]'
      data-filterable='true'
      data-navigatable='true'
      data-pageable='true'
      data-groupable='true'
      data-sortable='true'
      data-bind="source: userDataSource"></div>
    and the DataSource is being set in javascript like this:

    userDataSource: new kendo.data.DataSource({
    type: "aspnetmvc-ajax",
    transport: {
    read: {
    url: '/home/ListUsers'
    }
    },
    schema: {
    model: {
    id: 'ID',
    fields: {
    ID: {
    type: 'number'
    },
    Name: {
    type: 'string'
    },
    Group: {
    type: 'string'
    }
    }
    },
    data: 'Data',
    total: 'Total'
    },
    page: 1,
    pageSize: 30,
    serverPaging: true,
    serverSorting: true,
    serverFiltering: true,
    serverAggregates: true,
    serverGrouping: true
    })

    The ListUsers actions simply returns the corresponding data using DataSourceRequest, like this:

    public ActionResult ListUsers([DataSourceRequestDataSourceRequest request)
    {
      return Json(GetUsers().ToDataSourceResult(request));
    }


    By doing this, the grid is shown correctly, the paging, filtering and sorting all work fine, but not the grouping. I can see the column "drop area" and I can drag the column headers, but I can't drop them.
    I compared the grid properties with the script generated when using the MVC wrapper (using the wrapper, the grouping works) and I didn't see anything different that could be related to grouping. Am I missing something?

    Thanks!
  2. Answer
    Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2289 posts

    Posted 19 Dec 2012 Link to this post

    Hello Eduardo,

    There were some issues with MVVM initialization of groupable grid in the official release. You can download latest internal build from your account which contains fix for that behavior.

    Regards,
    Nikolay Rusev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top