sortingextjsmultiple-columnscase-insensitive

Extjs- Grid column sorting case insensitive


I am having a grid populated with search results. The sorting seems to be working fine if all the values in each column are numbers or if all of them are in the same case(upper or lower). But some of the columns in my grid like firstname and lastname are a mix of uppercase, lowercase and empty values. When I click on that particular header for sorting purpose, these values seems to be sorted as case sensitive. The uppercase values come one by one, then there are a mix of empty values and then the lowercase values. I want this sorting to be done as case insensitive alphabetically. I think extjs sorts these values based on the ascii values. Is there any way I can overwrite this functionality and where should I be doing that.

For example, I have some values like james, JAMESON and ROBERT. When I click on top of the header, if it ascending, I should be getting james, JAMESON and Robert and all the empty/null values together at the top or bottom. But that is not happening. I am getting some empty values on the top and then JAMESON, james, empty value again , ROBERT followed by empty/null values. How can I make sure all the null values are grouped together and the sorting should be case insensitive.

{
header: "User Last Name",
width: 170,
dataIndex: 'userLastName'
},
{
header: "User First Name",
width: 170,
dataIndex: 'userFirstName'
}

Thanks,


Solution

  • On the field in your model, define a sortType,

    http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.data.Field-cfg-sortType

    either as a function or as one of the predefined strings:

    http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.data.SortTypes

    I would guess that asUCText would be a good start, but I don't know what happens to null values there...