PDA

View Full Version : ddgrid issue



nadeemshafi9
16 Jun 2009, 5:16 AM
hi guys

i have a working example of sakis ddgrids and i use it but in this instance it for some reason is not applying the columns to grid1 but does to grid 2, only id gets added to grid 1, i checked teh json and even used the same json on grid1 that is on grid2 but it for some reason only whants to show id.


//////////////////////////////////// SAKIS STUFF ////////////////////////////////////////
/*
* @license ddgrids.js is licensed under the terms of the Open Source
* LGPL 3.0 license. Commercial use is permitted to the extent that the
* code/component(s) do NOT become part of another Open Source or Commercially
* licensed development library or toolkit without explicit permission.
*
* License details: http://www.gnu.org/licenses/lgpl.html
*/

Ext.ns('Example');

// {{{
Example.GridDropZone = function(grid, config) {
this.grid = grid;
Example.GridDropZone.superclass.constructor.call(this, grid.view.scroller.dom, config);
};
Ext.extend(Example.GridDropZone, Ext.dd.DropZone, {

onContainerOver:function(dd, e, data) {
return dd.grid !== this.grid ? this.dropAllowed : this.dropNotAllowed;
} // eo function onContainerOver

,onContainerDrop:function(dd, e, data) {
if(dd.grid !== this.grid) {
this.grid.store.add(data.selections);
Ext.each(data.selections, function(r) {
dd.grid.store.remove(r);
});
this.grid.onRecordsDrop(dd.grid, data.selections);
return true;
}
else {
return false;
}
} // eo function onContainerDrop

});

Example.Grid = Ext.extend(Ext.grid.GridPanel, {
// defaults - configurable from outside
border:false
,autoScroll:true
,viewConfig:{forceFit:true}
,layout:'fit'
,enableDragDrop:true
,initComponent:function() {
// hard coded config - cannot be changed from outside
var config = {
columns: [
{header: 'Id', width: 20, sortable: true},
{header: 'Name', width: 120, sortable: true},
{header: 'contact_id', width: 120, sortable: true}
]
};
// apply config
Ext.apply(this, Ext.apply(this.initialConfig, config));
// call parent
Example.Grid.superclass.initComponent.apply(this, arguments);
} // eo function initComponent

,onRender:function() {
Example.Grid.superclass.onRender.apply(this, arguments);
this.dz = new Example.GridDropZone(this, {ddGroup:this.ddGroup || 'GridDD'});
} // eo function onRender

/**
* Called when records are dropped on this grid
* @param {Ext.grid.GridPanel} srcGrid The source grid
* @param {Array} records Array of dropped records
*/
,onRecordsDrop:function(){
}
}); // eo extend

Example.Grid1 = Ext.extend(Example.Grid, {
initComponent:function() {
// hard coded config - cannot be changed from outside
var config = {
store:new Ext.data.JsonStore({
totalProperty: 'totalCount',
id: 'grid1store',
url: '/api/users/userspropertiesgridjson',
root: 'items',
autoLoad: true,
baseParams: {
user_id: m[0].data.id
},
fields: ['id','name', 'contact_id']
})
};
// apply config
Ext.apply(this, Ext.apply(this.initialConfig, config));
// call parent
Example.Grid1.superclass.initComponent.apply(this, arguments);
} // eo function initComponent
}); // eo extend
// register xtype
Ext.reg('examplegrid1', Example.Grid1);

Example.Grid2 = Ext.extend(Example.Grid, {
initComponent:function() {
// hard coded config - cannot be changed from outside
var config = {
store:new Ext.data.JsonStore({
url: '/api/users/propertiesgridjson',
root: 'items',
totalProperty: 'totalCount',
autoLoad: true,
id: 'ddgrid2store',
baseParams: {
user_id: m[0].data.id
},
fields: ['id','name', 'contact_id']
})
};
// apply config
Ext.apply(this, Ext.apply(this.initialConfig, config));
// call parent
Example.Grid2.superclass.initComponent.apply(this, arguments);
} // eo function initComponent
}); // eo extend
// register xtype
Ext.reg('examplegrid2', Example.Grid2);

Ext.BLANK_IMAGE_URL = './ext/resources/images/default/s.gif';
////////////////////////////////////////////////////////////////////////////////////////

thnx