PDA

View Full Version : complete initialConfig and the variables assigned in Ext.onReady.



dkjśrgaard
11 Jun 2013, 12:56 AM
Im trying to make a simple mini editor that can move objects from one container to another and saving the changes on the backed. So i could rearrange buttons or move some to the bbar from the tbar.

First problem is when i check the initialConfig of a grid, the containers (tbar and bbar) is still object references. Is there a way to get the tbar and bbar initialConfig as the string they were before object contruction.

Furthermore can i get a list of the variables assigned in the Ext.onReady scope? Something like the window object in normal javascript.

Any help or pointers would be appreciated.

Thanks.

-Danny

The initial simple drag'n'drop function.


Ext.Array.forEach(grid.getDockedItems('toolbar'),
function(e) {
var newLabel = Ext.create('Ext.form.Label', {
text: 'DropZone',
margin: '0 10 0 10',

});
var id = newLabel.id;
Ext.Array.forEach(e.items.items,
function (v){
v.dragZone = Ext.create('Ext.dd.DragZone', v.getEl(), {
getDragData: function(e) {
var sourceEl = e.getTarget(v.itemSelector, 10), d;
if (sourceEl) {
return v.dragData = {
sourceEl: sourceEl,
repairXY: Ext.fly(sourceEl).getXY(),
ddel: sourceEl,
elm: v
};
}
},

getRepairXY: function() {
return this.dragData.repairXY;
}
});
});
e.add(newLabel);
Ext.create('Ext.dd.DropTarget', id, {
notifyDrop: function (ddSource, e, data) {
Ext.getCmp(id).up().add(data.elm);
console.log(data.elm.initialConfig);
},
notifyEnter: function (ddSource, e, data) {
}
});
});

slemmon
13 Jun 2013, 1:28 PM
You can access the initial config in the initComponent before doing the callParent() method within initComponent. It might be best to store it in your own property for later access or you can go after the instance's proto's tbar property (see example below).

As for the variables assigned at onReady - I've not seen a list like that.



Ext.create('Ext.data.Store', {
storeId:'simpsonsStore',
fields:['name', 'email', 'phone'],
data:{'items':[
{ 'name': 'Lisa', "email":"lisa@simpsons.com", "phone":"555-111-1224" },
{ 'name': 'Bart', "email":"bart@simpsons.com", "phone":"555-222-1234" },
{ 'name': 'Homer', "email":"home@simpsons.com", "phone":"555-222-1244" },
{ 'name': 'Marge', "email":"marge@simpsons.com", "phone":"555-222-1254" }
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});


Ext.define('MyGrid', {
extend: 'Ext.grid.Panel',
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{ text: 'Name', dataIndex: 'name' },
{ text: 'Email', dataIndex: 'email', flex: 1 },
{ text: 'Phone', dataIndex: 'phone' }
],
height: 200,
width: 400,
tbar: [{
text: 'Test'
}],

initComponent: function () {
console.log(this.tbar);
// this.initialTbarConfig = this.tbar;
this.callParent(arguments);
console.log(this.__proto__.tbar);
}
});


Ext.create('MyGrid', {
renderTo: Ext.getBody()
});