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

Grid binding column order

5 Answers 238 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve asked on 13 Jun 2012, 06:57 PM
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.

5 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 14 Jun 2012, 07:02 AM
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!
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 14 Jun 2012, 12:26 PM
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?
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 14 Jun 2012, 12:55 PM
@Atanas
  You know what is borked though...

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

Try grouping...
0
Atanas Korchev
Telerik team
answered on 14 Jun 2012, 01:11 PM
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!
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 14 Jun 2012, 01:21 PM
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"
Tags
MVVM
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Answers by
Atanas Korchev
Telerik team
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Share this question
or