Multiple sort on Kendo Grid columns / DataSource - set sorting dynamically
<p>What I'm trying to accomplish is to apply an "automatic" secondary column sort when a user sorts a column in a kendo grid.</p>

<p>So in <a href="http://jsfiddle.net/dmathisen/0zz9zy97/" rel="nofollow">this JS fiddle example</a>, if a user sorts by "Value", it'll also sort by "Name". Note that the 0s are sorted together, but the names aren't alphabetical. I'd like them to be alphabetical (the secondary sort).</p>

<p><a href="http://jsfiddle.net/dmathisen/0zz9zy97/7/" rel="nofollow">Here's an attempt</a> at overriding the datasource sorting to accomplish this. I'm taking the user's original sort and the adding an additional sort on "SortedName". Based on the sorting array that's logged, it seems to be close but is still not working.</p>

<p>Any other ideas on how to accomplish this?</p>

<p>Note: I don't want to allow users to sort by multiple columns. The real world example I'm using this for can have up to 50+ columns (unfortunately), so multiple sort can get confusing / unintuitive. And I'd like it to be done behind the scenes without extra user interaction.</p>

<p>Example code for overriding kendo datasource sort():</p>

<pre><code>dataSource.originalSort = dataSource.sort;
dataSource.sort = function () {
    // take the user's sort and apply sorting on an additional column
    // the sort array should look like this:
    [
        { field: "Value", dir: "asc" }, // this is what the user sorted by
        { field: "SortedName", dir: "asc" }, // and I'm adding this
    ]
    return dataSource.originalSort.apply(this, arguments);
}
</code></pre>