View Full Version : [CLOSED] Performing sort on GridPanel when it has text with underscore

Jan 23, 2013, 4:37 PM
Sorting GridPanel when it has underscore text does not work as expected, as shown below:

Initial GridPanel's state

GridPanel's state after sort (ascending)

Note that the texts that begins with "_" are below those others. As far as i know it should be above.

<!DOCTYPE html>
<head id="Head1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:GridPanel Title="Ext.Net" runat="server" >
<ext:Store runat="server" >
<ext:AjaxProxy Url="/Example/LoadFakeRecords/">
<ActionMethods Read="POST" />
<ext:JsonReader Root="data" />
<ext:Model ID="Model2" runat="server">
<ext:ModelField Name="Name" SortType="AsUCText" Type="String" />
<ColumnModel runat="server">
<ext:RowNumbererColumn runat="server" />
<ext:Column Text="Name" DataIndex="Name" runat="server" />

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

public StoreResult LoadFakeRecords()
List<Entity> lst = new List<Entity>();

for (int index = 0; index < 15; index++)
lst.Add(new Entity
Name = index % 2 == 0 ? string.Format("Name{0}", index) : string.Format("_Name{0}", index),

return new StoreResult(lst, lst.Count());

public class Entity
public string Name { get; set; }

Jan 23, 2013, 4:45 PM
Please open console in your browser and input


For me it is true, it means that for ASC sorting '_Note' will be below 'Note0'

Jan 23, 2013, 4:48 PM
Also, it can be related with culture (not sure if javascript string comparing is culture sensitive (like in .NET))

Jan 23, 2013, 4:57 PM
Hi everybody,

I can confirm "_" > "N" returns true in IE9, Chrome and FireFox on my PC.

But this C# code returns -1.


Honestly, I don't know why this difference is. Maybe different encoding...

Anyway, RemoteSort="true" for the Store could be a solution.

Jan 23, 2013, 5:05 PM
"_note" > "note"

I think that it should work as i expected since i use SortType="AsUCText"

Jan 23, 2013, 5:08 PM
>> "_a".charCodeAt(0);
>> "_a".charCodeAt(1);

Jan 23, 2013, 5:22 PM
I think that it should work as i expected since i use SortType="AsUCText"

"AsUCText" converts text to upper case before comparing but A-Z codes 65-90
Underscore code is 95 therefore undescore > then symbol from A-Z
You can convert to lower case using CustomSortType of ModelField

<CustomSortType Handler="return String(value).toLowerCase().replace(Ext.data.SortT ypes.stripTagsRE, '');" />

Jan 23, 2013, 5:36 PM
Sorry Vladmir, i thought it was insensitive (http://forums.ext.net/showthread.php?10372-CLOSED-GridPanel-sortable-case-insensitive). Now i realized that UC means Upper Case :)

Thank you, your solution works like a charm.

Please mark this thread as closed.