Note that there are some explanatory texts on larger screens.

plurals
  1. POTelerik MVC Grid not sorting when reloaded
    primarykey
    data
    text
    <p>My Telerik MVC grid is Ajax bound and I need to ability to apply custom filtering via two checkboxes (in the DIV at the top). When a checkbox is checked, the parameters would be set and the grid is reloaded. This is working fine. During the initial load the data is sorted based on the sorting settings in Telerik, but after I click a checkbox, the data is ordered by record Id and no longer by Priority. If I then hit F5 the page is reloaded and the data is sorted correct. The sorting might be a parameter for grid.rebind() or provided in OnDataBinding, but so far I have not found what I am looking for. </p> <p>QUESTION: How do I specify the sorting order in the OnDataBinding or perhaps in another client event. </p> <p>Here is my code:</p> <hr> <pre><code>&lt;div style="float:right;width:600px;text-align:right"&gt; &lt;span&gt;My Items &lt;%=Html.CheckBox("newItems") %&gt;&lt;/span&gt; &lt;span&gt;Closed Items &lt;%=Html.CheckBox("Inactive") %&gt;&lt;/span&gt; &lt;/div&gt; &lt;% Html.Telerik().Grid&lt;IssueModel&gt;() .Name("Grid") .PrefixUrlParameters(false) .Columns(col =&gt; { col.Bound(o =&gt; o.Title); col.Bound(o =&gt; o.Priority).Width(50).Title("Priority ID"); col.Bound(o =&gt; o.PriorityName).Width(100).Title("Priority"); col.Bound(o =&gt; o.IssueStateName).Width(100).Title("Status"); col.Bound(o =&gt; o.AssignedToName).Width(140).Title("Assigned To"); }) .DataBinding(d =&gt; d.Ajax().Select("AjaxSelect", "Ticket", new { isNew = false, isInactive = false })) .ClientEvents(e =&gt; e.OnDataBinding("onDataBinding")) .Sortable(s =&gt; s .SortMode(GridSortMode.MultipleColumn) .OrderBy(order =&gt; { order.Add(o =&gt; o.Priority); order.Add(o =&gt; o.Sequence); }) ) .Pageable(p =&gt; p.PageSize(15)) .Filterable() .Render(); %&gt; </code></pre> <hr> <pre><code>&lt;script type="text/javascript"&gt; function onDataBinding(e) { e.data = { isNew: $("#newItems").is(':checked'), isInactive: $("#Inactive").is(':checked') }; e.orderBy = "Severity~desc~Ranking~asc"; } $("input[type='checkbox']").click(function () { var grid = $('#Grid').data('tGrid'); var param = { isNew: $("#newItems").is(':checked'), isInactive: $("#Inactive").is(':checked') }; grid.rebind(param); }); &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload