PDA

View Full Version : [CLOSED] Validation of the dragged records from source grid in listener



Sowjanya
Aug 15, 2013, 3:36 AM
Hi,

I am looking for a solution that would do validation of the records that are being dragged from left grid to right grid. suppose, I drag the first record
(hi hi123) from left grid to right grid, now a listener ( i guess drop handler / a handler even before the records are actually droppped on right grid...I am not sure of theexact handler here...) has to fire that says "the record with ID=1 is already assigned to some other object. ( actually, i am doing this check in the code behind by calling web service. I am trying to call the direct method from listener...If you can get me a simple solution, thats fine...)

Example left grid:

(this left grid has store and model defined. The store also has ID column..but is not shown on the grid.

Col1 Col2
----------------------------
hi hi123
bye bye123


Right Grid:

(this right grid has store and model defined. The store also has ID column..but is not shown on the grid.


Col1 Col2
---------------------------
hello hello123
hey hey123

I have seen many examples like :

http://examples2.ext.net/#/DragDrop/Grid/Grid_to_Grid/
etc... but getting script errors.

Looking forward to get a solution...

Thanks,
Veda

Daniil
Aug 15, 2013, 6:03 AM
Hi Veda,

Please use a GridView's BeforeDrop listener.
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.grid.plugin.DragDrop-event-beforedrop

Example

<BeforeDrop Fn="onBeforeDrop" />

var onBeforeDrop = function (node, data, overModel, dropPosition, dropHandlers) {
dropHandlers.wait = true;

App.direct.ValidateDrop(data.records[0].get("Name"), {
success: function (result) {
if (result) {
dropHandlers.processDrop();
} else {
dropHandlers.cancelDrop();
alert("Denied");
}
}
});
};

[DirectMethod]
public bool ValidateDrop(string name)
{
return name == "Rec 2";
}

You can test it with the example that you mentioned.
http://examples2.ext.net/#/DragDrop/Grid/Grid_to_Grid/