View Full Version : [CLOSED] [#699] Disable remote sort and sort locally

Feb 10, 2015, 11:12 AM
On the following example

Select the records 3, 4, 5 and 6 in this specific order, then click Show Only Selected Records button

The remote sort was disabled, then local sort was performed (Lines 21 to 24), but unfortunately with no effect, the sort was not performed correctly.
Note that it's sorted by ID, descending, but the records are sorted by ID ascending.

On version 2.x, it works as expected.
Note: to run the example on version 2.x it's necessary to rename JsonReader's RootProperty to Root.

Thanks in advance.

<!DOCTYPE html>
<head runat="server">
<script type="text/javascript">
var ShowOnlySelectedRecords = function () {

var grid = App._grd;
var store = App._grd.store;

var selectedRecords = new Array();

for (var index = 0; index < App._sm.selected.length; index++) {



//Sort locally
var originalSort = store.remoteSort;
store.remoteSort = false;
store.remoteSort = originalSort;
<ext:ResourceManager ScriptMode="Debug" runat="server" />
<ext:GridPanel ID="_grd" Title="Ext.Net" Border="true" Width="500" Height="300" runat="server">
<ext:Store PageSize="10" RemoteSort="true" AutoLoad="true" runat="server">
<ext:DataSorter Property="ID" Direction="DESC" />
<ext:AjaxProxy Url="~/Example/LoadFakeRecords/" StartParam="start" LimitParam="limit" PageParam="page" SortParam="sort">
<ActionMethods Read="POST" />
<ext:JsonReader RootProperty="data" />
<ext:Model IDProperty="ID" runat="server">
<ext:ModelField Name="ID" Type="Int" />
<ext:ModelField Name="Name" Type="String" />
<ColumnModel runat="server">
<ext:Column Text="ID" DataIndex="ID" runat="server" />
<ext:Column Text="Name" Flex="1" DataIndex="Name" runat="server" />
<ext:CheckboxSelectionModel ID="_sm" Mode="Multi" runat="server" />
<ext:Button Text="Show Only Selected Records" runat="server">
<Click Handler="ShowOnlySelectedRecords();" />

namespace SandBox.Controllers
public class ExampleController : System.Web.Mvc.Controller
public ActionResult Index()
return View();

public StoreResult LoadFakeRecords(int start, int limit, int page, string sort)
List<Entity> lst = new List<Entity>();

for (int index = start; index < (page * limit); index++)
lst.Add(new Entity
ID = index,
Name = string.Format("Name - {0}", index)

lst = Sort(lst, sort);

return new StoreResult(lst, (page * limit) + limit);

public List<Entity> Sort(List<Entity> lst, string sort)
DataSorter sortDefinition = DataSorter.From(sort).FirstOrDefault();

var parameter = Expression.Parameter(typeof(Entity));

Func<Entity, Object> function = Expression.Lambda<Func<Entity, IComparable>>(Expression.Convert(Expression.Property(parameter, sortDefinition.Property), typeof(IComparable)), parameter).Compile();

if (sortDefinition.Direction == SortDirection.ASC)
return lst.OrderBy(function).ToList();
return lst.OrderByDescending(function).ToList();

public class Entity
public int ID { get; set; }

public string Name { get; set; }

Feb 11, 2015, 6:32 PM
Hello Raphael,

I've tried your sample and yes it does not perform sorting. But I also noticed that the grid ill behaves after the javascript code runs. The last added row remains checked and if I click the button again I get error:

TypeError: record is undefined

Maybe it is related to the original issue. Nevertheless, I will run a few more tests.

Feb 11, 2015, 7:12 PM
The last added row remains checked and if I click the button again I get error:

TypeError: record is undefined

Dimitris, honestly i haven't tested the sample as a whole. I just reproduced the issue, since in my real-world scenario it's quite more complex.

Can you list the steps to get the error. I would appreciate to reproduce it.

Thank you.

Feb 11, 2015, 7:17 PM
Dimitris, please replace




Feb 12, 2015, 10:30 AM
Well, yes, no sorting. It is like the call to sort() is ignored. I have added a BeforeSort listener but it never gets fired, too.

Let me try with v.2.x and check a few things to decide if it is an intended change of behavior or a bug.

Theoretically speaking, I am not quite following the logic behind this mix of client and server side sorting considering that RemoteSort=true causes the data to be loaded from the server every time.

Feb 12, 2015, 10:49 AM

Feb 12, 2015, 3:25 PM
Certainly Raphael. After testing with 2.x. I do think this is a bug. I will post again as soon as we open an issue.

Issue (https://github.com/extnet/Ext.NET/issues/699) created.

Feb 12, 2015, 3:31 PM
Thank you.

Feb 13, 2015, 9:05 AM
Hello everybody,

This should be used

instead of

store.remoteSort = false;

So, the end of the ShowOnlySelectedRecords should look:

var originalSort = store.remoteSort;

Please confirm it is working for you.

Seems not a bug.

Feb 13, 2015, 9:22 AM
I confirm it works for me. We can close the issue and the thread and move it out of Bugs as soon as Raphael confirms it works, too.

Feb 13, 2015, 11:10 AM
I confirm. Please mark this thread as closed.

This should be used


It makes sense. I should have checked by myself. Sorry for that.