-
30 Oct 2012 5:57 AM #1
Answered: Sortable list draggable reset issue
Answered: Sortable list draggable reset issue
I am trying to create a sortable list with Sencha Touch 2.0 . I am following Sencha Touch 1.1 Ext.util.Sortable class source code. I made some progress - that is the dragging and moving the element while other elements movements work perfectly.
However, I am kind of finding issues while using draggable.reset() function as well as dropping the draggable element to drop in the new position. Here is some parts of the codes which i am using:
Code:if (region.bottom > item.top && item.top > region.top) { draggable._element.insertAfter(item.el); } else { draggable._element.insertBefore(item.el); } sortChange = true;I am trying to figure out how to drop the draggable component in "dragend" event. However, I am not getting how I need to set offset with comparing with other list items'. Any help?Code:if (sortChange) { // We reset the draggable (initializes all the new start values) draggable.refreshOffset(); // draggable.reset(); // Move the draggable to its current location (since the transform is now different) draggable._element.setXY([region.left, region.top]); // Finally lets recalculate all the items boxes this.calculateBoxes(); this.fireEvent('sortchange', this, draggable._element, this.element.query('.x-list-item', false).indexOf(draggable._element.dom)); return; }Swarnendu
Co-founder & Lead Architect @ Innofied
------------------
I blog at http://www.swarnendude.com
-
Best Answer Posted by mitchellsimoens
What you should really do is change the index of the record in the store and let the dataview/list handle keeping things in order.
-
1 Nov 2012 5:03 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,107
- Vote Rating
- 453
- Answers
- 3155
What you should really do is change the index of the record in the store and let the dataview/list handle keeping things in order.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
7 Nov 2012 10:52 PM #3
Thanks Mitchell. It worked fine. I kept a reference of the changed index on "drag" event and moved the record in Store on "dragend" event. Added a list.refresh() in the end.
Swarnendu
Co-founder & Lead Architect @ Innofied
------------------
I blog at http://www.swarnendude.com
-
23 Nov 2012 5:17 AM #4
Hello,
Could you share your code.
I'm very interest by a sortable list.
Thank you.
-
23 Nov 2012 5:24 AM #5
I have attached the code (only the required files) here in this thread as attachment:
http://www.sencha.com/forum/showthread.php?249836-setScrollable(false)-refreshes-List.-How-to-prevent&p=914576&viewfull=1#post914576
However, attaching here too.Swarnendu
Co-founder & Lead Architect @ Innofied
------------------
I blog at http://www.swarnendude.com
-
23 Nov 2012 6:05 AM #6



Reply With Quote