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.
Unfortunately, activation email could not send to your email. Please try again.

Context Menu for several selected records

Thread ID:

Created:

Updated:

Platform:

Replies:

127023 Oct 21,2016 06:23 AM Oct 26,2016 01:27 AM JavaScript 3
loading
Tags: ejGrid
Carlos Rodríguez García
Asked On October 21, 2016 06:23 AM

Hi,

I understand the context menu is by default operating on the selectedRecord.

When I right click on a row, even if before I had selected several of them, only that records gets selected and the context menu appears.

Is there a way so that when I right click to open the context menu, my selection does not change to that single row and it keeps all previous rows selected? This way I would be able to apply context menu "actions" to several rows at a time.

Thank you in advance for your help.

Kind regards,
Carlos

Madhu Sudhanan P [Syncfusion]
Replied On October 24, 2016 09:48 AM

Hi Carlos, 

Currently the Grid will clear the selection when context menu is opened.  But we can achieve your requirement with the below code example. 


       var cached; //Local variable to store selected indexes 
        
       $("#Grid").ejGrid({ 
 
            dataSource: window.gridData, 
            selectionType: 'multiple', 
            contextMenuSettings: { enableContextMenu: true }, 
            . . .  . .  
            contextOpen: function () { 
                if (cache) 
                    this.selectRows(cache); //Select after context menu open 
            }, 
            rowSelecting: function (args) { 
 
                //Store the selected indexes which can be selected after context opened. 
 
                if (this.selectedRowsIndexes.length > 1) { 
                    cache = this.selectedRowsIndexes.slice(0); 
                    cache.push(args.rowIndex); 
                } 
                else { 
                    cache = null; 
                } 
            } 
        }); 


In the above code example we have stored the selected indexes in the rowSelecting event and re-selected them after context menu opened in the contextOpen event. 




Regards, 
Madhu Sudhanan P 


Carlos Rodríguez García
Replied On October 25, 2016 09:05 AM

Thank you very much, this worked perfect.

Madhu Sudhanan P [Syncfusion]
Replied On October 26, 2016 01:27 AM

 
We are happy that your requirement is achieved. 
 
Please get back to us if you require further assistance. 
 
Thanks & regards, 
Madhu Sudhanan P 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;