Grid binding column order

6 posts, 0 answers
  1. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 13 Jun 2012 Link to this post

    If I specify my grid headers like this:
    data-columns='[{"field": "pdrID", "title":"PdrID"},
                                       {"field": "rotationName", "title":"Rotation"},
                                       {"field": "siteCapacityID", "title":"CapacityID"},
                                       {"field": "ruleID", "title":"RuleID"},
                                       {"field": "userID", "title":"UserID"},
                                       {"field": "name", "title":"Student"},
                                       {"field": "location", "title":"Site"},
                                       {"field": "statusDesc", "title":"Status"},
                                       {"field": "pref", "title":"Pref"},
                                       {"field": "campusName", "title":"Campus"},
                                       {"field": "startDate", "title":"Start"},
                                       {"field": "endDate", "title":"End"}
                                      ]'

    I would expect that since I'm telling it which field to match up, that I could control the order that the data item displays in.  However it seems to render the columns based on the JSON property order instead.

    So lets say the above is the correct order the json is coming down in, if I swapped the first two header items, theyd render swapped, but the data would bind as it did before, so the pdrs would be in the rotations column and visa versa.

  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 14 Jun 2012 Link to this post

    Hi Steve,

     I am not sure what you mean. The grid columns are displayed in the order they are declared. Here is a jsFiddle which proves that: http://jsfiddle.net/korchev/7juMP/1/ 

    Regards,
    Atanas Korchev
    the Telerik team
    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. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 14 Jun 2012 Link to this post

    Wow, sorry left out a critical piece of info there

    http://jsfiddle.net/stevescotthome/undF5/1/

    ...row template

    But as I type this I realize how ridiculous this is so....nevermind :) ...there's no way to tell the templates <TD> that it corrosponds to a field to respect the header order right?
  5. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 14 Jun 2012 Link to this post

    @Atanas
      You know what is borked though...

    http://jsfiddle.net/stevescotthome/undF5/2/

    Try grouping...
  6. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 14 Jun 2012 Link to this post

    Hi Steve,

     I don't see any cells generated for the groups in your template. Check this forum thread how to create a template which is grouping aware: http://www.kendoui.com/forums/ui/grid/grid-grouping-problem-when-using-row-template-bug.aspx 

    Regards,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  7. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 14 Jun 2012 Link to this post

    You should mark that for documentation, there's no way anyone will remember to add this :)

    #= new Array(this.group().length + 1).join('<td class="k-group-cell"></td>') #

    ...why would that not just be added to the grid automatically (internally) when grouping+templating is used?...seems pretty boilerplate, nothing custom or fancy.

    It'd even be cool as a JustCode refactoring..."Oh you've enabled Grouping and templating, but your template is missing a group column"
Back to Top
Kendo UI is VS 2017 Ready