10

I have 4 grids that have the drag and drop plugin enabled. Their initial grid is dependent on a value from the db called state_id.

When I drop the selected row into a new grid, I update the state_id value and then tell it to sync up with the db and update the value for the item in question.

enter image description here

This works fine for the most part. I get this URL is undefined error when the following happens

  1. User clicks drags row A from grid 1 to grid 2
  2. User drags row A from grid 2 to grid 1
  3. ERROR! Url undefined.

This error only seems to happen when the first item being added to the grid originally came from the same grid.

  1. User clicks drags row A from grid 1 to grid 2
  2. User clicks drags row B from grid 2 to grid 1
  3. User clicks drags row A from grid 2 to grid 1
  4. Works as intended!

drop event handler inside my controller:

dropit: function (node, data, dropRec, dropPosition) {
    if (node.dragData.records[0].store.$className == "AM.store.BacklogCards")
    {
        data.records[0].set('state_id', 1);
        this.getBacklogCardsStore().sync();
    }
    else if (node.dragData.records[0].store.$className == "AM.store.InprogressCards")
    {
        data.records[0].set('state_id', 2);
        this.getInprogressCardsStore().sync();
    }
    else if (node.dragData.records[0].store.$className == "AM.store.ReviewCards")
    {
        data.records[0].set('state_id', 3);
        this.getReviewCardsStore().sync();
    }
    else
    {
        data.records[0].set('state_id', 4);
        this.getDoneCardsStore().sync();
    }
    //node.dragData.records[0].store.sync();
},

Any ideas on what is causing this and how to fix it?

Thanks

RoboKozo
  • 4,981
  • 5
  • 51
  • 79
  • In your first test case, do things work as expected if "User drags row A from grid 2 to grid 3"? – Amol Katdare Jul 08 '11 at 21:20
  • Yeah it works fine. The issue seems to be when it goes back to its 'original' location before anything else is put into that same (original) location. – RoboKozo Jul 09 '11 at 19:00
  • 1
    If the error is "url undefined", then it seems like the problem is not there, but in your actual store definitions. Note that sometimes this sort of error can occur because of the use of IDs in class definitions, as IDs must be unique and so strange failures will occur when instantiating objects. – Tamzin Blake Oct 19 '11 at 14:57
  • what point release are you on? the latest? – JamesHalsall Nov 03 '11 at 13:16

2 Answers2

1

May I suggest that you use one store instead of three, and simply add three equal grids all using the same store, but with filtering on state=?

That way you can simply update the status on drop, refresh the two involved grids and synch the one store.

Gaute Løken
  • 7,522
  • 3
  • 20
  • 38
0

It looks like whenever your dropit function is called, you are only syncing one store. Shouldn't you be syncing the store the item came from and the store it was dropped on? It seems to me that the phantom deletion records would still be hanging around in the original store, this would cause two records to exist when you drag that record back in since the from store was never synced to remove that record.

Reimius
  • 5,694
  • 5
  • 24
  • 42