beforeUpdate

This event occurs before updating values in database and can cancel default update statement (see error, invalid and success methods below). It can also be used to validate incoming values (see the SetInvalid() method below).

connector.BeforeUpdate += new EventHandler<DataActionProcessingEventArgs>(connector_BeforeProcessing);

In the code string above connector_BeforeProcessing() function gets event argument with DataAction object that represents current action.

Validation usage:

//validate user's attempt to rename file or folder
void connector_BeforeUpdate(object sender, DataActionProcessingEventArgs e)
{
   if (e.DataAction.Data[(this.Connector as dhtmlxTreeConnector).NodeTextField] == "")//if tree node text value is empty
   e.DataAction.SetInvalid("File name cannot be empty!");
}

Setting error:

//deny update operation  
void connector_BeforeUpdate(object sender, DataActionProcessingEventArgs e)
{
   e.DataAction.SetFailed("Operation denied!");//just deny operation without any reason
}

Modifying update action:

//add one more field into update action
void connector_BeforeUpdate(object sender, DataActionProcessingEventArgs e)
{
   e.DataAction.Data.Add("modify_date", Tools.ConvertToString(DateTime.Now));
}

Cancelling default update action and replacing it with own logic:

void connector_BeforeUpdate(object sender, DataActionProcessingEventArgs e)
{
   e.DataAction.SetCompleted();
   //execute own update logic
}
Back to top