Hi,
I want to check start and end dates of a task when editing, and to cancel the action if they are weekend days. I need this validation for some tasks, not all. I use dialog and taskbar editing.
In OnActionBegin event with "BeforeSave" request type, args.Data shows original data and args.RowData is null. After that OnActionComplete event is triggered and args.Data shows new data. I can only check the data in OnActionComplete but setting args.Cancel at that phase doesn't take the action back, so I need to cancel at OnActionBegin-BeforeSave.
I tried to get old data in OnActionBegin and set the datasource with old data in OnActionComplete or even later with a button click. I see the data changes at the backend but gantt doesn't load the data I set. Using RefreshAsync, RefreshColumnsAsync, StateHasChanged functions did not work. I could only work around by reloading the grid with old data but it is not a nice solution, showing a full refresh. I think the neatest solution would be canceling the action in "OnActionBegin" event.
Is there a way to accomplish this?
Thanks & best regards
Hi Divya,
The feedback is private. Can you grant access so that I can review the solution please?
Kind regards
Yunus
Hi Monisha,
Thank you. I'll be waiting for the feedback's solution.
Hi Divya,
About the solution you offered about "DialogEditing";
"
For dialog editing Action, you can get the original data from GanttActionEventargs.Rowdata in action begin event. After editing , you will get the edited data in GanttActionEventargs.Data with “BeforeSave” request type. Now, You can compare the date and cancel the editing action if it is on weekend. "
I previously tried this, and it wasn't working. I tried it again after you wrote, but still it's not working. BeforeSave request type shows the original data, not the edited data, like I wrote in problem description:
"
In OnActionBegin event with "BeforeSave" request type, args.Data shows original data and args.RowData is null. After that OnActionComplete event is triggered and args.Data shows new data. I can only check the data in OnActionComplete but setting args.Cancel at that phase doesn't take the action back, so I need to cancel at OnActionBegin-BeforeSave."
I cancel the operation and do not write to db in OnActionComplete, because I can only get the edited data at that phase. But the gantt reserves the last (edited) data, doesn't take the action back. So I need to make a full refresh to show the correct data.
Can you please check the scenario again?
Thanks & best regards