We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Task Delete/Default context menu options remove

1) Currently i'm using this code to delete the workitem
function ActionComplete(args) {    
    if (args.requestType == "delete") {
        args.cancel = true;
        if (confirm("All the child tasks,if any will also get deleted? Are you sure you want to delete this task? ")) {
           ....Code to delete item.....   
        }
    }   
}

The problem with this approach is, i'm able to restrict the delete operation but still,task gets deleted from the UI. I can perform this operation on actionBegin event also,but in that case,Delete operation conficts with Row drag & drop functionality. Because i'm getting args.requestType=delete inside actionBegin even while droping row on another row. Would you please help me to resolve this?

2) Another problem is,how i can remove default context menu items. I'm not able to perform my custom opration on 'Task Details' click because i'm opening my custom add task dialogue using args.requestType == "beforeOpenEditDialog". In case of clicking task details,i'm also getting args.requestType == "beforeOpenEditDialog".

So in other words,i would like to remove all the default items of context menu except add task and then i will add my required items into it using args.contextMenuItems.push......

3) Duration is currently being displayed as 'days',how to change it to hours(hrs)? e.g. my model returns 8 hrs but duration displays it as 8 days.

3 Replies

JS Jonesherine Stephen Syncfusion Team December 16, 2016 12:23 PM UTC

Hi Kuntal, 
Please find the response below: 
Query 
Response 
The problem with this approach is, i'm able to restrict the delete operation but still,task gets deleted from the UI. I can perform this operation on actionBegin event also,but in that case,Delete operation conficts with Row drag & drop functionality. Because i'm getting args.requestType=delete inside actionBegin even while droping row on another row. Would you please help me to resolve this? 
On drag/drop action, the record will be deleted from the dragged position and it will be added in a dropped position. So delete action will be triggered in this case. To restrict this, we can set/reset the flag in rowDrag and rowDragStop action respectively. 
By using that flag value we can perform delete action 
Please find the code example below: 
<script> 
    var rowDragStart=false;     
    function actionBegin(args) { 
        if (args.requestType == "delete") { 
            if (rowDragStart!=true){ 
            args.cancel = true; 
            if (confirm("All the child tasks,if any will also get deleted? Are you sure you want to delete this task? ")) { 
                // ....Code to delete item.....    
            } 
            }            
        }    
    }     
    function rowDrag(args) { 
        rowDragStart = true; 
    } 
    function rowDragStop(args) { 
        rowDragStart = false; 
    } 
    </script> 
 
Another problem is,how i can remove default context menu items. I'm not able to perform my custom opration on 'Task Details' click because i'm opening my custom add task dialogue using args.requestType == "beforeOpenEditDialog". In case of clicking task details,i'm also getting args.requestType == "beforeOpenEditDialog". 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
We can add the custom context menu items by using contextMenuOpen client side event. We have prepared the work around and removed all default menu and included custom TaskDetails Menu and bind the edit action by using “openEditDialog” public method. 
By using eventHandler we can bind the actions to custom menu 
Please find the code example below: 
function contextMenuOpen(args) { 
        //to remove the default menu 
        args.contextMenuItems = [];       
       //To add the custom context menu 
        var contextMenuItems = [{ 
            headerText: "Task Details", 
            eventHandler: customEditMenuHandler, 
            menuId: "Taskcustom",           
            iconClass: "e-editIcon" 
        }, { 
            headerText: "Custom menu 1", 
            menuId: "menu1",           
            eventHandler: customMenuAddHandler,             
        }, 
        { 
            headerText: "Custom menu 2", 
            menuId: "menu2",             
            eventHandler: customMenuAddHandler,             
        },         
          
        ]; 
        args.contextMenuItems.push.apply(args.contextMenuItems, contextMenuItems); 
    } 
    //To bind action for custom menu 
    function customEditMenuHandler(args) {         
        var ganttObj = $("#GanttContainer").data("ejGantt"); 
        //To open the edit dialog 
        ganttObj.openEditDialog(); 
         
    } 
    function customMenuAddHandler(args) { 
        alert("we can bind the custom action here"); 
    } 
Please find our online documentation for further reference 
 Duration is currently being displayed as 'days',how to change it to hours(hrs)? e.g. my model returns 8 hrs but duration displays it as 8 days. 
We can change the duration units by using durationUnit property.Please find the code example below 
@(Html.EJ().Gantt("GanttContainer") 
.DurationUnit(GanttDurationUnit.Hour) 
)@(Html.EJ().ScriptManager()) 
 
We have also prepared the sample in version 14.4.0.15 for your reference. Please find the sample from below location 
Regards, 
Jone sherine P S 



KP Kuntal Patel December 19, 2016 07:30 AM UTC

Thanks Jone sherine for the response.

Delete function will not work as per you mentioned because actionBegin fires before any event. I found a work around which is working as expected. 

if (args.isDragAndDropDelete != true) {......This is the delete operation without drag and drop....}

Contextmenu and Duration unit worked as expected. Thanks again.




JS Jonesherine Stephen Syncfusion Team December 20, 2016 05:20 AM UTC

Hi Kuntal, 
Thanks for the update. 
Please let us know if you need further assistance on this. 
Regards, 
Jone sherine P S 


Loader.
Up arrow icon