X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/ee06f37b0f6f6d94cd05a6ffae556660f7c4a2bc..c930e9176a5a85509c5b0230e2bff5c22a591432:/examples/dd/dnd_grid_to_grid.js diff --git a/examples/dd/dnd_grid_to_grid.js b/examples/dd/dnd_grid_to_grid.js index 67140d62..e563f202 100644 --- a/examples/dd/dnd_grid_to_grid.js +++ b/examples/dd/dnd_grid_to_grid.js @@ -1,21 +1,11 @@ -/* - * Ext JS Library 2.2.1 - * Copyright(c) 2006-2009, Ext JS, LLC. - * licensing@extjs.com - * - * http://extjs.com/license - */ - -/* - * Ext JS Library 2.1 - * Copyright(c) 2006-2009, Ext JS, LLC. - * licensing@extjs.com - * - * http://extjs.com/license - */ - +/*! + * Ext JS Library 3.0.0 + * Copyright(c) 2006-2009 Ext JS, LLC + * licensing@extjs.com + * http://www.extjs.com/license + */ Ext.onReady(function(){ - + var myData = { records : [ { name : "Rec 0", column1 : "0", column2 : "0" }, @@ -38,14 +28,14 @@ Ext.onReady(function(){ {name: 'column1', mapping : 'column1'}, {name: 'column2', mapping : 'column2'} ]; - + // create the data store var firstGridStore = new Ext.data.JsonStore({ fields : fields, data : myData, root : 'records' }); - + // Column Model shortcut array var cols = [ @@ -53,17 +43,17 @@ Ext.onReady(function(){ {header: "column1", width: 50, sortable: true, dataIndex: 'column1'}, {header: "column2", width: 50, sortable: true, dataIndex: 'column2'} ]; - + // declare the source Grid var firstGrid = new Ext.grid.GridPanel({ - ddGroup : 'secondGridDDGroup', + ddGroup : 'secondGridDDGroup', store : firstGridStore, columns : cols, - enableDragDrop : true, + enableDragDrop : true, stripeRows : true, autoExpandColumn : 'name', width : 325, - region : 'west', + region : 'west', title : 'First Grid' }); @@ -71,21 +61,21 @@ Ext.onReady(function(){ fields : fields, root : 'records' }); - + // create the destination Grid var secondGrid = new Ext.grid.GridPanel({ - ddGroup : 'firstGridDDGroup', + ddGroup : 'firstGridDDGroup', store : secondGridStore, columns : cols, - enableDragDrop : true, + enableDragDrop : true, stripeRows : true, autoExpandColumn : 'name', width : 325, - region : 'center', + region : 'center', title : 'Second Grid' }); - + //Simple 'border layout' panel to house both grids var displayPanel = new Ext.Panel({ width : 650, @@ -103,7 +93,7 @@ Ext.onReady(function(){ handler : function() { //refresh source grid firstGridStore.loadData(myData); - + //purge destination grid secondGridStore.removeAll(); } @@ -123,19 +113,19 @@ Ext.onReady(function(){ ddGroup : 'firstGridDDGroup', copy : true, notifyDrop : function(ddSource, e, data){ - + // Generic function to add records. function addRow(record, index, allItems) { - + // Search for duplicates - var foundItem = firstGridStore.find('name', record.data.name); + var foundItem = firstGridStore.findExact('name', record.data.name); // if not found if (foundItem == -1) { firstGridStore.add(record); - + // Call a sort dynamically firstGridStore.sort('name', 'ASC'); - + //Remove Record from the source ddSource.grid.store.remove(record); } @@ -145,28 +135,28 @@ Ext.onReady(function(){ Ext.each(ddSource.dragData.selections ,addRow); return(true); } - }); + }); + - // This will make sure we only drop to the view container var secondGridDropTargetEl = secondGrid.getView().el.dom.childNodes[0].childNodes[1] - + var destGridDropTarget = new Ext.dd.DropTarget(secondGridDropTargetEl, { ddGroup : 'secondGridDDGroup', copy : false, notifyDrop : function(ddSource, e, data){ - + // Generic function to add records. function addRow(record, index, allItems) { - + // Search for duplicates - var foundItem = secondGridStore.find('name', record.data.name); + var foundItem = secondGridStore.findExact('name', record.data.name); // if not found if (foundItem == -1) { secondGridStore.add(record); // Call a sort dynamically secondGridStore.sort('name', 'ASC'); - + //Remove Record from the source ddSource.grid.store.remove(record); } @@ -175,5 +165,5 @@ Ext.onReady(function(){ Ext.each(ddSource.dragData.selections ,addRow); return(true); } - }); + }); });