View Full Version : Ext.ux.grid.DataDrop, and default records

11 Mar 2010, 6:29 AM

I'm dragging and dropping data into a grid which works fine. What I would like to do is on the drop create some default additional fields in the grid. Does anyone do anything like this?



12 Mar 2010, 9:10 AM
I have a grid I'm dragging and dropping to and I'm using the Ext.ux.DataDrop plugin.

My grid I'm dragging to has 9 columns but the data I'm dragging has only 4 columns, the first 4 columns of the grid.

I need to derive the other grid columns based on other fields.

I've added a listener to the add event on the grid's store to attempt to populate the fields but I'm running into problems.

I've added the listener like this:

'add' : {
fn: function(store, record, index) {
record[0].set('coverId', 1);
scope: this

The problem I have is the plugin only creates its record based on the dragged records and not the underlying store of the grid. So in my example, coverId doesn't exist in the dragged records so doesn't exist in record. So I need to create a field and set its value.

I guess I have two questions, first is the add listener the correct place to do this sort've manipulation and is there a way I can add fields to an existing record?

The errors I'm seeing are a bit odd, I'm getting a blank first row in the grid.



12 Mar 2010, 12:46 PM
I had the same thing to work on. I would say use Ext.dd.DropTarget and catch the 'notifyDrop' that way u can write ur custom function to move the rows to the other grid and add new columns to the records .
something like this

// grid1 is the grid with 4 columns , grid2 with 9 columns
var ddrow = new Ext.dd.DropTarget(grid2.getEl(), {
ddGroup : 'GridDD',
notifyDrop : function(dd, e, data){
//Select all the rows the where dragged from the grid
var rows= grid.getSelectionModel().getSelections();

for (i = 0; i < rows.length; i++)
// remove the row from the dragged grid which had 4 columns

var record = rows[i];

// SET all the columns u want to ......
record.set('coverId', 1);
// then add the record to the grid with 9 columns ......