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

edit the contextmenu item

when i user the ejSpreadsheet,i want to change the items of contextmenu when i select a row and right click. how to solve it? thank you!

3 Replies

SI Silambarasan I Syncfusion Team June 30, 2016 09:20 AM UTC

Hi Xycool, 
Thank you for your interest in Syncfusion products. 
Your requirement “To change the items of Row header context menu in Spreadsheet” can be achieved by using ‘dataSource’ (ejMenu) property in ‘beforeOpen’ client-side event.  We have prepared a sample to demonstrate this and the same can be downloaded from the following link.  Please refer the below code example. 
$(function () { 
        beforeOpen: "beforeCMenuOpen" 
function beforeCMenuOpen(args) { 
    var cMenuObj, newDataSource; 
    if ($(args.target).hasClass("e-rowheader")) { 
        cMenuObj = $("#" + this._id + "_contextMenuRowHeader").data("ejMenu"); 
              //Here we can get the default dataSource of context menu 
              //var defaultDataSource = cMenuObj.model.fields.dataSource 
        //Change menu options 
        newDataSource = [ 
        if (JSON.stringify(cMenuObj.model.fields.dataSource) !== JSON.stringify(newDataSource)) { 
            cMenuObj.setModel({ fields: { dataSource: newDataSource } }); 
    args.cancel = true; //Prevent default process here 
Sample Link: 
Silambarasan I 

XY xycool July 5, 2016 03:42 AM UTC

Thank you ,I use your solution to my problem,but i make a suggestion,you give me the  sample,i find a mistake.

  else if ($(args.target).hasClass("e-rowcell")) {
                var contentCMenu = $("#" + this._id + "_contextMenuRowHeader").data("ejMenu");

"_contextMenuRowHeader" should be "_contextMenuCell".

Anyway, thank you for your answer

SI Silambarasan I Syncfusion Team July 5, 2016 05:49 AM UTC

Hi Xycool, 
We deeply regret for the inconvenience caused.  
We have accepted your suggestion and you can use “this._id + ‘_contextMenuCell’” to get the sheet content ejMenu object.  
Silambarasan I 

Live Chat Icon For mobile
Up arrow icon