sencha touch SortableListの使用

1896 ワード

回転:sencha touch 2.3 SortableList pluginを1つ増やし、list itemのドラッグ交換を実現
Ext.require('Ext.plugin.SortableList');
Ext.create('Ext.List', {
    fullscreen: true,
    // Set the class to the name you passed in for the handleSelector
    itemTpl: '<div class="gripper">{title}</div>',
    data: [
        { title: 'Item 1' },
        { title: 'Item 2' },
        { title: 'Item 3' },
        { title: 'Item 4' }
    ],

    // These are required to fix a bug that exists in the plugin
    infinite: true,
    variableHeights: true,

    plugins: [
        { xclass: 'Ext.plugin.SortableList', handleSelector: '.gripper' }
    ],

    listeners: [
        {
            event: 'dragsort',
            fn: function (listObject, row, to, from) {
                console.log(from + ' ' + to);
            }}
    ]
});