PDA

View Full Version : Drag & Drop To Different Model



azinyama
1 Oct 2012, 5:11 AM
Good day all!!!

I have three different models that look like this:



Ext.define('ClaimCatch_RIS.model.Tariff',
{
extend: 'Ext.data.Model',

fields :
[
{
name: 'Tariff_RowID',
type: 'int'
},
{
name: 'Tariff_Code',
type: 'string'
},
{
name: 'Tariff_Descr',
type: 'string'
},
{
name: 'Tariff_NAMAS',
type: 'float'
},
{
name: 'Tariff_AFHOZ',
type: 'float'
},
{
name: 'Tariff_Cash',
type: 'float'
}
]
});





Ext.define('ClaimCatch_RIS.model.TariffGroup',
{
extend: 'Ext.data.Model',

fields :
[
{
name: 'Group_RowID',
type: 'int'
},
{
name: 'Procedure_RowID',
type: 'int'
},
{
name: 'Group_Descr',
type: 'string'
}
]
});





Ext.define('ClaimCatch_RIS.model.TariffGroupTariff',
{
extend: 'Ext.data.Model',

fields :
[
{
name: 'Group_Tariff_RowID',
type: 'int'
},
{
name: 'Group_RowID',
type: 'int'
},
{
name: 'Tariff_Code',
type: 'string'
},
{
name: 'Group_Tariff_Qty',
type: 'int'
},
{
name: 'Modifier_Descr',
type: 'string'
}
]
});


I have three grids: 'Tariffs', 'TariffGroup' and 'TariffGroupTariff'. I am dragging a row from 'Tariffs' and dropping it in 'TariffGroupTariff'. Grid 'TariffGroupTariff'will show the Tariff_Code that is because grid 'Tariffs' has the same feild. And that is where I'm getting stuck; because what I want to also happen is:
Before I drag I would have selected a row from grid 'TariffGroup' and I want Group_RowID to be passed to grid 'TariffGroupTariff';
And I would like 'Group_Tariff_Qty' and 'Modifier_Descr' to have the default values 1 and '00' set respectively when the selected row is dropped into 'TariffGroupTariff'.
Any suggestions on how I could do this...

scottmartin
1 Oct 2012, 10:43 AM
You should be able to update the record in the store for each. Here is a quick example of 3 grids.
http://www.sencha.com/forum/showthread.php?239658

Scott.

azinyama
3 Oct 2012, 10:56 PM
Thanks for the reply, but I don't think that is what I'm look for. The three grids in the example all have the same columns. Think I didn't explain myself properly. Here is an image of the girds:

39129

Tariff - Contains list of all available tariffs
TariffGroup - Is a group that consists of a any number of tariffs
TariffGroupTariff - List of tariffs that are in TariffGroup

Looking at the image above what happens is, when I select a group (CT Scan - Joints) the tariffs that are in that group are listed below in TariffGroupTariff.
When I want to add another tariff to the group I drag it from Tariff and drop it in TariffGroupTariff.

My question is:
TariffGroupTariff has a column 'Group_RowID' whose value I wanted assigned from the selected group (CT Scan - Joints)in TariffGroup.

scottmartin
4 Oct 2012, 7:58 AM
You could use record.set() to update the field based on the dropped record:



var record = ddSource.dragData.selections[0];
var fieldName = secondGrid.getColumnModel().getDataIndex(col);
var value = record.get(fieldName);


Scott.

azinyama
4 Oct 2012, 9:41 AM
Hi!!! Thanx for the reply. I have tried to do that, but with no luck.I'm using the rowediting plugin, so when I drag the Tariff to TariffGroupTariff it is dropped and fires the create method, at which point the value hasn't been set. Then in the beforedrop drop event I use the record.set() which then sets the value and fires the create method again. How do I go about stopping from firing the before I set the value. Thought that if I set it the the beforedrop event would only fire once.