PDA

View Full Version : Treegrid sort error - n1.attributes[p] is undefined



trtechservices
28 Apr 2010, 5:50 AM
I am running the treegrid example out of the box using ExtJs 3.2.1 and getting this error:

n1.attributes[p] is undefined at
var v1 = sortType ? sortType(n1) : (cs ? n1.attributes[p] : n1.attributes[p].toUpperCase());

The tree is not loaded howewer the request response contains the valid JSON string.

The code that's causing is below. Somehow the sorttype variable doesn't seem to be populated


Ext.ux.tree.TreeGridSorter.superclass.constructor.apply(this, arguments);

this.tree = tree;
tree.on('headerclick', this.onHeaderClick, this);
tree.ddAppendOnly = true;

me = this;
this.defaultSortFn = function(n1, n2){

var dsc = me.dir && me.dir.toLowerCase() == 'desc';
var p = me.property || 'text';
var sortType = me.sortType;
var fs = me.folderSort;
var cs = me.caseSensitive === true;
var leafAttr = me.leafAttr || 'leaf';

if(fs){
if(n1.attributes[leafAttr] && !n2.attributes[leafAttr]){
return 1;
}
if(!n1.attributes[leafAttr] && n2.attributes[leafAttr]){
return -1;
}
}
var v1 = sortType ? sortType(n1) : (cs ? n1.attributes[p] : n1.attributes[p].toUpperCase());
var v2 = sortType ? sortType(n2) : (cs ? n2.attributes[p] : n2.attributes[p].toUpperCase());

if(v1 < v2){
return dsc ? +1 : -1;


I tried with my custom treegrid and got same error. The treegrid display my data the sort function failed with the same error.

Is it an environment issue?
Any advice is welcome.

Thanks

sbuemaint
28 Apr 2010, 12:31 PM
I reported this in the bugs : http://www.extjs.com/forum/showthread.php?92149-OPEN-578-TreeGrid-sorting-does-not-work-at-all-in-IE

I fixed it by changing the calls to sortType like this:


var v1 = sortType ? sortType(n1.attributes[p]) : (cs ? n1.attributes[p] : n1.attributes[p].toUpperCase());
var v2 = sortType ? sortType(n2.attributes[p]) : (cs ? n2.attributes[p] : n2.attributes[p].toUpperCase());

trtechservices
5 May 2010, 10:17 AM
Thanks for the answer, but that's definitely not my issue. I have 2 treegrids. For one the sort is working great for the second one I have this error: n1.attributes[p] is undefined at...

I compare the 2 DOM for the 'me' object (see desc above) and found the following differences:
Attributes 'dir' and 'sorttype' (var sortType = me.sortType;) are missing, thus making the var v1 fail.

Any idea why the sorttype is missing?