-
13 Aug 2012 4:30 PM #1
NestedList NodeInterface insertChild does not display in correct order in List
NestedList NodeInterface insertChild does not display in correct order in List
REQUIRED INFORMATION
Ext version tested:- Sencha Touch 2.0.1.1
- Chrome 21.0.1180.75 m
- html
- In Touch 2.0.1.1 (and 2.0), inserting an item does insert it into the children, but the inserted item is displayed at the end of the List.
- Run the code below.
- Tap on Drinks, then Water, then any row
- The Insert row should be in front of the row just tapped, but it is as the end.
- Back all the way back to Groceries and then forward again to Waters and you will see that it is now in the correct position. This is because there are only 2 Lists in a NestedList and the List has been refreshed, showing the actual position from the node's children.
HELPFUL INFORMATIONCode:Ext.setup({ onReady: function () { var data = { text: 'Groceries', items: [{ text: 'Drinks', items: [{ text: 'Water', items: [{ text: 'Sparkling', leaf: true }, { text: 'Still', leaf: true }, { text: 'Deep', leaf: true }, { text: 'Muddy', leaf: true }] }] }] }; Ext.define('ListItem', { extend: 'Ext.data.Model', config: { fields: [{ name: 'text', type: 'string' }] } }); var store = Ext.create('Ext.data.TreeStore', { model: 'ListItem', defaultRootProperty: 'items', root: data }); var nestedList = Ext.create('Ext.NestedList', { fullscreen: true, title: 'Groceries', displayField: 'text', store: store, listeners: { leafitemtap: function (nlist, list, index, element, record, e, opts) { console.log(record.get("text")); //record.parentNode.appendChild({ "text": "Added", "leaf": true }); record.parentNode.insertChild(index, { "text": "Inserted", "leaf": true }); if (false) { // should work but does not list.getStore().sort([{ "property": "text", "direction": "ASC"}]); } if (false) { // Does work record.parentNode.sort(function (rec1, rec2) { var val1 = rec1.get("text"); var val2 = rec2.get("text"); if (val1 > val2) { return 1; } if (val1 = val2) { return 0; } return -1; }, false, false); } if (false) { // Also should work but does not record.parentNode.sort([{ "property": "text", "direction": "ASC"}]); } } } }); } });
Screenshot or Video:- none
Debugging already done:- none
- not provided
- only defaults .css
- Windows 7
Last edited by drb; 15 Aug 2012 at 11:25 AM. Reason: Modified last Step to reproduce to be clearer.
-
15 Aug 2012 11:15 AM #2Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Redwood City, California
- Posts
- 3,659
- Vote Rating
- 14
Thank you for the report. This may have been fixed in a patch version, we'll verify and get back to you.
-
16 Aug 2012 10:15 AM #3Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Redwood City, California
- Posts
- 3,659
- Vote Rating
- 14
Scenario 1: Since NestedList uses a TreeStore, you would need to sort the nlist in your example instead of the list.
Scenario 2: This works here because you are calling the nodeInterface's sort method directly and use a sortFn.
Scenario 3: This doesn't work because nodeInterface's sort method doesn't currently accept that syntax.
We're looking into what can be done to help make this easier in the future. Note that much of the reasoning behind how it works now is we don't have a very good way to determine if the call to sort is coming from an internal method (the TreeStore) or a developer call (just a NodeInterface). This can lead to recursion problems in the current implementation and it's why we have some of the limitations.
-
29 Aug 2012 8:01 PM #4
Above comment belongs with the Sort bug I reported
Above comment belongs with the Sort bug I reported
Jamie,
Can you move the comment to the right bug?
Thanks David
-
29 Aug 2012 8:02 PM #5
Is there any workaround for the failure to display in the right order?
Is there any workaround for the failure to display in the right order?
Thanks
David
-
18 Apr 2013 9:53 AM #6Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Haarlem, Netherlands
- Posts
- 1,235
- Vote Rating
- 5
I'm pretty sure this issue has been fixed as part of a previous release. The testcases we have for this issue (which is based on your provided testcase) runs correctly in the 2.2 codebase for me.
Please let me know if anyone still has this issue or something related to it and I will reopen.
Best,
Tommy
Success! Looks like we've fixed this one. According to our records the fix was applied for
TOUCH-3259
in
Sprint 33.


Reply With Quote
