Opened 10 years ago

Closed 10 years ago

#10877 closed defect (invalid)

Nested sorting fails in EnhancedGrid for XmlStore

Reported by: fphan Owned by: Jared Jurkiewicz
Priority: high Milestone: tbd
Component: DojoX Data Version: 1.4.2
Keywords: XmlStore EnhancedGrid sort Cc:
Blocked By: Blocking:

Description

When using XmlStore? in EnhancedGrid?, nested sorting fails.

Attachments (9)

simpleGrid.html (3.5 KB) - added by fphan 10 years ago.
HTML using EnhancedGrid? with XmlStore?
movies.xml (1.0 KB) - added by fphan 10 years ago.
xml data
EnhancedGridXmlStore_ascSort.PNG (40.7 KB) - added by fphan 10 years ago.
Screen shot showing ascending sort (yes, the stupid down arrow means ascending sort)
EnhancedGridXmlStore_desSort.PNG (41.7 KB) - added by fphan 10 years ago.
Screen shot showing descending sort (yes, the stupid "x" means descending sort)
XMLStore-nestedSorting-issue1.jpg (180.5 KB) - added by evan 10 years ago.
XMLStore-nestedSorting-issue2.jpg (86.7 KB) - added by evan 10 years ago.
test_data_grid_XMLStores.html (2.2 KB) - added by evan 10 years ago.
books-clean.xml (178 bytes) - added by evan 10 years ago.
test_data_grid_XMLStores_comparatorMap.html (2.7 KB) - added by Jared Jurkiewicz 10 years ago.
Demonstration of using comparator maps to work with comparing items in a specific way (in this case, text content)

Download all attachments as: .zip

Change History (15)

Changed 10 years ago by fphan

Attachment: simpleGrid.html added

HTML using EnhancedGrid? with XmlStore?

Changed 10 years ago by fphan

Attachment: movies.xml added

xml data

comment:1 Changed 10 years ago by Adam Peller

Owner: changed from bryanforbes to Evan

see also #10859

Changed 10 years ago by fphan

Screen shot showing ascending sort (yes, the stupid down arrow means ascending sort)

Changed 10 years ago by fphan

Screen shot showing descending sort (yes, the stupid "x" means descending sort)

comment:2 Changed 10 years ago by fphan

Note: The two attached screen shots above illustrates attempts at sorting by year after having sorted by producer. The two titles by Ridley Scott always stay in the same order.

comment:3 Changed 10 years ago by evan

This is caused by a defect in XMLStore which results in nested sorting failure.

Suppose using the following xml as XMLStore, we have two columns "title", "isbn" <books>

<book>

<isbn>2</isbn> <title>b</title>

</book> <book>

<isbn>2</isbn> <title>a</title>

</book>

</books>

When XMLStore doing sort by using dojo.data.util.sorter, see line 56 of dojo.data.util.sorter.js: ... return function(itemA, itemB){

var a = s.getValue(itemA, attr); var b = s.getValue(itemB, attr); return dir * comp(a,b); int

}; ... here both a and b are returned as html dom node reference rather than value text for comparison, pls see "XMLStore-nestedSorting-issue1.jpg"

then "comp(a,b)" always return -1 as none if condition will be matched, please see "XMLStore-nestedSorting-issue2, that's the reason why nested sorting are not working well.

To reproduce this issue, please put the attached "test_data_grid_XMLStores.html" under dojox/grid/tests/ and put attached "books-clean.xml" under dojox/grid/tests/support/ for try.

Changed 10 years ago by evan

Changed 10 years ago by evan

Changed 10 years ago by evan

Changed 10 years ago by evan

Attachment: books-clean.xml added

comment:4 Changed 10 years ago by Adam Peller

Component: DojoX GridDojoX Data

comment:5 Changed 10 years ago by Adam Peller

Owner: changed from Evan to Jared Jurkiewicz

comment:6 Changed 10 years ago by Jared Jurkiewicz

Resolution: invalid
Status: newclosed

This is working correctly for the defined data type. isbn and title are XML nodes, and therefore full items themselves. That is why it returns them for the value. XML nodes are more than just text content, thet could have attributes, sub nodes, etc.

If you want to compare just the text content, you need to define a comparator map to do that, much like you would for custom item comparisons in ItemFile?*Store. I've attached an example of comparing isbin and title by using the 'toString()' function on all item handles returned by XMLStore. you could also do it as:

xmlStore.getValue(a, "text()"); To get the text content of the XML node.

Changed 10 years ago by Jared Jurkiewicz

Demonstration of using comparator maps to work with comparing items in a specific way (in this case, text content)

Note: See TracTickets for help on using tickets.