3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
21 Ext.define('DataObject', {
22 extend: 'Ext.data.Model',
23 fields: ['name', 'column1', 'column2']
26 Ext.onReady(function(){
29 { name : "Rec 0", column1 : "0", column2 : "0" },
30 { name : "Rec 1", column1 : "1", column2 : "1" },
31 { name : "Rec 2", column1 : "2", column2 : "2" },
32 { name : "Rec 3", column1 : "3", column2 : "3" },
33 { name : "Rec 4", column1 : "4", column2 : "4" },
34 { name : "Rec 5", column1 : "5", column2 : "5" },
35 { name : "Rec 6", column1 : "6", column2 : "6" },
36 { name : "Rec 7", column1 : "7", column2 : "7" },
37 { name : "Rec 8", column1 : "8", column2 : "8" },
38 { name : "Rec 9", column1 : "9", column2 : "9" }
41 // create the data store
42 var firstGridStore = Ext.create('Ext.data.Store', {
48 // Column Model shortcut array
50 {text: "Record Name", flex: 1, sortable: true, dataIndex: 'name'},
51 {text: "column1", width: 70, sortable: true, dataIndex: 'column1'},
52 {text: "column2", width: 70, sortable: true, dataIndex: 'column2'}
55 // declare the source Grid
56 var firstGrid = Ext.create('Ext.grid.Panel', {
60 ptype: 'gridviewdragdrop',
61 dragGroup: 'firstGridDDGroup',
62 dropGroup: 'secondGridDDGroup'
65 drop: function(node, data, dropRec, dropPosition) {
66 var dropOn = dropRec ? ' ' + dropPosition + ' ' + dropRec.get('name') : ' on empty view';
67 Ext.example.msg("Drag from right to left", 'Dropped ' + data.records[0].get('name') + dropOn);
71 store : firstGridStore,
78 var secondGridStore = Ext.create('Ext.data.Store', {
82 // create the destination Grid
83 var secondGrid = Ext.create('Ext.grid.Panel', {
86 ptype: 'gridviewdragdrop',
87 dragGroup: 'secondGridDDGroup',
88 dropGroup: 'firstGridDDGroup'
91 drop: function(node, data, dropRec, dropPosition) {
92 var dropOn = dropRec ? ' ' + dropPosition + ' ' + dropRec.get('name') : ' on empty view';
93 Ext.example.msg("Drag from left to right", 'Dropped ' + data.records[0].get('name') + dropOn);
97 store : secondGridStore,
100 title : 'Second Grid',
104 //Simple 'border layout' panel to house both grids
105 var displayPanel = Ext.create('Ext.Panel', {
114 defaults : { flex : 1 }, //auto stretch
122 items: ['->', // Fill
124 text: 'Reset both grids',
126 //refresh source grid
127 firstGridStore.loadData(myData);
129 //purge destination grid
130 secondGridStore.removeAll();