1. #1
    Sencha User swarnendude's Avatar
    Join Date
    Jul 2009
    Location
    Kolkata, India
    Posts
    117
    Vote Rating
    0
    Answers
    1
    swarnendude is on a distinguished road

      0  

    Default 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;
    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;
    }
    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?
    Swarnendu
    Co-founder & Lead Architect @ Innofied

    ------------------
    I blog at http://www.swarnendude.com

  2. 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.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,641
    Vote Rating
    434
    Answers
    3107
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    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.

  4. #3
    Sencha User swarnendude's Avatar
    Join Date
    Jul 2009
    Location
    Kolkata, India
    Posts
    117
    Vote Rating
    0
    Answers
    1
    swarnendude is on a distinguished road

      0  

    Default


    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

  5. #4
    Sencha User
    Join Date
    Mar 2011
    Posts
    17
    Vote Rating
    0
    Petitbomber is on a distinguished road

      0  

    Default


    Hello,
    Could you share your code.
    I'm very interest by a sortable list.

    Thank you.

  6. #5
    Sencha User swarnendude's Avatar
    Join Date
    Jul 2009
    Location
    Kolkata, India
    Posts
    117
    Vote Rating
    0
    Answers
    1
    swarnendude is on a distinguished road

      0  

    Default


    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

    H
    owever, attaching here too.
    Attached Files
    Swarnendu
    Co-founder & Lead Architect @ Innofied

    ------------------
    I blog at http://www.swarnendude.com

  7. #6
    Sencha User
    Join Date
    Mar 2011
    Posts
    17
    Vote Rating
    0
    Petitbomber is on a distinguished road

      0  

    Default


    Thank you...