Get resource on onMenuItemSelect

Hi all,

We have a lot of grouped resources, like shown in this image:

Scherm­afbeelding 2024-04-17 om 19.48.52.png

How do I get the resource from the selected cell ( for example '1 AW handmatig - WV-LV-95 ) after selecting an option from the context menu?

Right now I have:

var selectedCells = scheduleObj.getSelectedElements();

var activeCellsData = scheduleObj.getCellDetails(selectedCells.length > 0 ? selectedCells : selectedTarget);

var i = activeCellsData.groupIndex;

Which gives me the groupIndex,  but I can't figure out how to get the associated resource. 


3 Replies

VR Vijay Ravi Syncfusion Team April 18, 2024 09:22 AM UTC

Hi Marc,


Based on your requirement, we checked and prepared the Scheduler sample to retrieve the resource from the selected cell after selecting an option from the context menu. We suggest you use the groupID that has been passed in the getResourcesByIndex() method to get the resource data, as shown in the shared code snippet below.


[index.cshtml]
 

var selectedCells = scheduleObj.getSelectedElements();

var activeCellsData = scheduleObj.getCellDetails(selectedCells.length > 0 ? selectedCells : selectedTarget);

if (selectedMenuItem === 'Add') {

     scheduleObj.openEditor(activeCellsData, 'Add');

} else {

     scheduleObj.openEditor(activeCellsData, 'Add', null, 1);

}

// Get the resource details

var resourceDetails = scheduleObj.getResourcesByIndex(activeCellsData.groupIndex);

console.log(resourceDetails);



Output screenshot:



Refer to our shared sample for your reference and get back to us with the required details for further assistance.


Regards,

Vijay


Attachment: get_resource_details_with_context_menu_7d6db9ee.zip


MW Marc Walen April 18, 2024 09:52 AM UTC

Thank you. I tried that before but gave me an error. After copying your code it did work, so I probably had a typo.



RV Ravikumar Venkatesan Syncfusion Team April 19, 2024 07:01 AM UTC

Hi Marc,

You are welcome.

We are happy our shared code helped you achieve your requirements.

Regards,
Ravikumar Venkatesan


Loader.
Up arrow icon