PDA

View Full Version : Don't allow drop of record grid (gridviewdragdrop)



fabio.policeno
3 Nov 2011, 9:24 AM
Hello
I need to block the line of the grid drop if the value of column1 is 0, for this example: http://docs.sencha.com/ext-js/4-0/#!/example/dd/dnd_grid_to_grid.html

I tried like this, but I view returns the error dropZone is not defined(view.dropZone.lock()).



viewConfig: {
...
listeners: {
...
beforedrop: function(node, data, dropRec, dropPosition) {
if(data.records[0].get('column1') == 0)
{
data.view.dropZone.lock();
}
else
{
data.view.dropZone.unlock();
}
}
}
},


Thank's!

mitchellsimoens
3 Nov 2011, 10:02 AM
If you want to cancel a drop, return false in the beforedrop. before events should all be cancelable by returning false.

fabio.policeno
3 Nov 2011, 11:04 AM
Perfect!!

But now found other problem:


verificarExisteTurma: function(dragZone, item){
var me = this,
registros = item.records;

Ext.each(registros, function(registro){
var idAnoAcademico = registro.get('IDAnoAcademico'),
idNivelEnsino = registro.get('IDNivelEnsino');

Ext.Ajax.request({
url : URLADMIN + '/turma/existeAnoAcademico/',
params : {
IDAnoAcademico: idAnoAcademico,
IDCliente : me.idRegistro
},
success: function(resposta){
var r = Ext.decode(resposta.responseText);
if(r.existe){

return false;
}
}
});
})
}


In resume, if r.existe return true, like stop drop. But i don't have idea how.

Thank's!

fabio.policeno
4 Nov 2011, 4:48 AM
I decided to bring the value of the validation model and it worked. Thank you!