Sorting a Grid bound to array...

3 posts, 0 answers
  1. Robin
    Robin avatar
    46 posts
    Member since:
    Jul 2012

    Posted 08 Jul 2014 Link to this post

    Is it possible to set the sort of a grid that is bound to a simple array ?  I know I could make the array into a dataSource and add sorting that way, but this array is a child of an object which the entire template is bound to, so I use the value bindings for a grid to the child array.

    See jsbin sample http://jsbin.com/haciba/1/edit 

    Do I need to sort this data ahead of time, before I create the observable, or is there a way to declaratively set the sorting on the grid ?

    Thanks,

    Robin
  2. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 10 Jul 2014 Link to this post

    Hi Robin,

    Yes it is possible to set the sort order via data attributes. Please see the updated example:
    <div id="grid"
      data-role="grid"
      data-sortable="true"
      data-columns="[{field: 'c', title: 'Color'},
      {field: 'order', title: 'Order'}]"
      data-source='{"sort": { "field": "order", "dir": "asc"}}'
      data-bind="source: colors">
    </div>


    Regards,
    Alexander Valchev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Robin
    Robin avatar
    46 posts
    Member since:
    Jul 2012

    Posted 10 Jul 2014 Link to this post

    Thank you so much.  Works perfectly.
Back to Top