Posting here in case this helps anyone else:
I had a case where I needed to bind a simply JSON object to a listView. The issue was that the listView when using grouping sorts on the group field, so if you have:
And chose to do this:
Then the resulting list will be oddly sorted:
0-11, 10-30, 8-20
The trick here is to sort by one field but use another in the headerTemplate:
And then use a function as the headerTemplate to use another field completely:
This allows you to create your own sort by creating a specific "order" field without having to use it as the group title.
I had a case where I needed to bind a simply JSON object to a listView. The issue was that the listView when using grouping sorts on the group field, so if you have:
data = [
{ band: '0-11', text: 'Some text here' },
{ band: '8-20', text: 'Some text here' },
{ band: '10-30', text: 'Some text here' } ];
kendo.data.DataSource.create( { data: data, group: "band" } )
0-11, 10-30, 8-20
The trick here is to sort by one field but use another in the headerTemplate:
data = [
{ band_order: '1.0-11', band: '0-11', text: 'Some text here' },
{ band_order: '2.8-20', band: '8-20', text: 'Some text here' },
{ band_order: '3.10-30', band: '10-30', text: 'Some text here' } ];
And then use a function as the headerTemplate to use another field completely:
$("#myList").kendoMobileListView( {
dataSource : kendo.data.DataSource.create( { data: bands, group: "band_order" } ),
template : $("#mytemplate").html(),
headerTemplate: function(data) { return data.items[0].band; } } );