Opened 12 years ago
Closed 12 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)
Change History (15)
Changed 12 years ago by
Attachment: | simpleGrid.html added |
---|
Changed 12 years ago by
Attachment: | EnhancedGridXmlStore_ascSort.PNG added |
---|
Screen shot showing ascending sort (yes, the stupid down arrow means ascending sort)
Changed 12 years ago by
Attachment: | EnhancedGridXmlStore_desSort.PNG added |
---|
Screen shot showing descending sort (yes, the stupid "x" means descending sort)
comment:2 Changed 12 years ago by
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 12 years ago by
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 12 years ago by
Attachment: | XMLStore-nestedSorting-issue1.jpg added |
---|
Changed 12 years ago by
Attachment: | XMLStore-nestedSorting-issue2.jpg added |
---|
Changed 12 years ago by
Attachment: | test_data_grid_XMLStores.html added |
---|
Changed 12 years ago by
Attachment: | books-clean.xml added |
---|
comment:4 Changed 12 years ago by
Component: | DojoX Grid → DojoX Data |
---|
comment:5 Changed 12 years ago by
Owner: | changed from Evan to Jared Jurkiewicz |
---|
comment:6 Changed 12 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
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 12 years ago by
Attachment: | test_data_grid_XMLStores_comparatorMap.html added |
---|
Demonstration of using comparator maps to work with comparing items in a specific way (in this case, text content)
HTML using EnhancedGrid? with XmlStore?