Resource Assignment

Hi,

Is it possible to change resource assignment type from multiple to single ? i.e. Radio button instead of checkbox or restricting choosing multiple resources per task.


7 Replies 1 reply marked as answer

MS Monisha Sivanthilingam Syncfusion Team December 16, 2021 06:08 AM UTC

Hi Halit, 
 
Greetings from Syncfusion support. 
 
We have made use of the openAddDialog and openEditDialog request types in the actionComplete event to check if the tab chosen is the Resources tab, and then restricted the selection to only a single resource. The below code snippets demonstrate the solution. 
 
Index.cshtml 
 
<script> 
  function actionComplete(args) { 
    if ( args.requestType == "openAddDialog" || args.requestType == "openEditDialog") { 
      var tabObj = document.getElementById("resource_Tab").ej2_instances[0]; 
      tabObj.selected = function (args) { 
        if (args.selectedItem.innerText == "RESOURCES") { 
          var resourceTab = document.getElementById("resourceResourcesTabContainer_gridcontrol").ej2_instances[0]; 
          resourceTab.selectionSettings = { 
            checkboxOnly: false, 
            type: "Single", 
            persistSelection: false 
          }; 
        } 
      }; 
    } 
  } 
</script> 
 
 
 
Please contact us if you require any further assistance. 
 
Regards, 
Monisha. 



HA Halit December 16, 2021 06:57 AM UTC

Hi Manisha,

 I couldn't manage to work that at my side. 

PS. I will also need a way to prevent multi-select at in-line editing (on TreeGrid)

PS.2 Also can't add screenshot to this post. Attaching it.

Attachment: screenshot_dcbed4.zip


PP Pooja Priya Krishna Moorthy Syncfusion Team December 20, 2021 01:03 PM UTC

Hi Halit, 

We have made use of the openAddDialog and openEditDialog request types in the actionComplete event to prevent multi-select in Dialog, At present, we do not have the support to prevent the multi-select at cell editing(on Treegrid) , we have shared a sample and code snippet  for your reference which will prevent multiselect in dialog 
 
 
function actionComplete(args) { 
        if (args.requestType == "openAddDialog" || args.requestType == "openEditDialog") { 
 
            var tabObj = document.getElementById("resource_Tab").ej2_instances[0]; 
            tabObj.selected = function (args) { 
 
        if (args.selectedItem.innerText == "RESOURCES") { 
                    var resourceTab =             document.getElementById("resourceResourcesTabContainer_gridcontrol").ej2_instances[0]; 
                    resourceTab.columns.splice(0, 1); 
                    resourceTab.selectionSettings = { 
                        type: "Single", 
                        persistSelection: false 
                    }; 
                    
                } 
            }; 
 
 
 
Please contact us for further assistance  
 
Regards, 
 
Premkumar S 
 



HA Halit December 21, 2021 06:36 AM UTC

Hi,

Thanks, it worked but there is a side effect: Already assigned resource is not in selected after opening resource dialog. Is there an option for that ?


"At present, we do not have the support to prevent the multi-select at cell editing(on Treegrid) "


So, is there a way to prevent cell editing (treegrid) but allow dialog editing for that particular field ?



PP Pooja Priya Krishna Moorthy Syncfusion Team December 22, 2021 12:39 PM UTC

Hi Halit, 
  
We have achieved your requirement by using cellEdit event and also using openEditDialog request type. We have prepared a sample and also add code snippets for your reference 
  
Code snippets: 
Events:  
  
function cellEdit(args) { 
        if (args.columnName == "Resources") { 
  
            args.cancel = true
  
        } 
    } 
  
Request type:  
function actionComplete(args) { 
if (ganttArgs.requestType == 'openEditDialog') { 
  
                    //To maintain selected resources in resource tab 
                     
  
                    var resources = ganttObj.selectionModule.getSelectedRecords()[0].ganttProperties.resourceInfo; 
  
                    var currentViewData = resourceTab.getCurrentViewRecords(); 
  
                    currentViewData.forEach(function (data, index) { 
  
                        for (var i = 0; i < resources.length; i++) { 
  
                            if (data.taskData[ganttObj.resourceFields.id] === resources[i][ganttObj.resourceFields.id]) { 
  
                                resourceTab.selectRow(index); 
  
                            } 
  
                        } 
  
                    }); 
  
                } 
  
  
  
Please contact us for further assistance  
  
Regards, 
Premkumar S 


Marked as answer

LS Liam Sammy May 15, 2025 02:54 AM UTC

# Resource Assignment Example in Python


# List of employees

employees = ["Ali", "Sara", "John", "Aisha"]


# List of tasks

tasks = ["Prepare report", "Conduct training", "Update database", "Schedule interviews"]


# Assign tasks to employees (round-robin assignment)

assignment = {}


for i, task in enumerate(tasks):

    employee = employees[i % len(employees)]

    assignment[task] = employee


# Display the assignments

print("Resource Assignment:")

for task, employee in assignment.items():

    print(f"- {task} → {employee}")


This code ensures that tasks are distributed evenly among employees using a simple round-robin method. If you're working on a project or need help with HR-related coding for your coursework, especially this kind of example can be very useful. Let me know if you want it tailored for more complex scenarios like skill matching or availability.



AG Ajithkumar Gopalakrishnan Syncfusion Team May 16, 2025 11:55 AM UTC

Hi Liam,

Thank you for your response.

Please contact us if you require any further assistance.

Regards,
Ajithkumar G


Loader.
Up arrow icon