Grid

Hi,
I need the grid to copy the row only once
and not allow the user to do it again, how I can do this?
Thanks for your help,
Regards.

I suppose we are talking about d-n-d.
Grid provides onDrag event handler, which receives all info about row moving ( copying ) and from which you can return false to block operation.

so you can attach custom code to onDrag event, check from it is dnd need to be allowed and return true or false to confirm or deny operation.

Thanks Stanislav.
I don’t mean to dnd, I refer to next function
function CopyRow(){
var rowId=mygrid.getSelectedId()
mygrid.addRow(rowId+“n”,"",mygrid.getRowIndex(rowId)+1);
alert ( “Adiciona renglon” );
mygrid.copyRowContent(rowId, rowId+“n”);
mygrid.cells(rowId+“n”,3).setValue("");
mygrid.cells(rowId+“n”,4).setValue(“2060-12-31”);
alert ( “despues de copy” );
}
I want to copy only once on click button.
If already copy don’t user make again.
Regards.

You can flag row as copied to prevent double call

[code]
function CopyRow(){
var rowId=mygrid.getSelectedId()

if (mygrid.getUserData(rowId, "Copy")) return;  //prevent double call
mygrid.setUserData(rowId, "Copy", "done");       //set flag[/code]

Stanislav,
Thanks for your help. Operates correctly.
Regards.

Hi Stanislav,
I have other question.
When I copy row need validate before sendData one cell in origin row and cell copy row.
Like this:
var v1 = mygrid.cells(rowId+“n”,3).getValue();
var v2 = mygrid.cells(rowId,4).getValue();

v1 > v2 (both dates).
How to validate whether these cells are dates and how time?
Thanks, regards.

You can use the next event for validation

dp.attachEvent(“onBeforeUpdate”, function(id, state, data){
//your validation logic here
});

As for data validation, if cell in question is of dhxCalendar type, you can use

var val1 = grid.cells(i,j).getDate()

instead of get value, it will return native date object, which you can use for comparation
If you are using string values - you need to implement your own date parsing|comparation logic.