contextmenu

Hi,

i use a contextmenu in dhtmlxgrid, and by select an item “addNotes” in contextmenu must be create a window. In window, i have attached a grid too. I have following codes:



function onButtonClick(menuitemId,type){

dhxWins= new dhtmlXWindows();

dhxWins.setImagePath("/images/windows_imgs/");

dhxWins.setSkin(“clear_blue”);

dhxWins.enableAutoViewport(false);

dhxWins.attachViewportTo(“mygrid_container”);



var data=mygrid.contextID.split("_");

var rowId = data[0];

var cellInd = data[1];

    

if( menuitemId == “addNotes”){

        

    var w1 = dhxWins.createWindow(“w1”,0,0,250,100);

    w1.setText(“addNotes”);

    w1.center();

    dhxWins.window(“w1”).addUserButton(“save”, 3, “save”, “tray”);

    dhxWins.window(“w1”).button(“save”).attachEvent(“onClick”, function(){

        dp.sendData();

    });

    var grid = w1.attachGrid();

    grid.setImagePath("/images/imgs/");

    grid.setHeader(“Model”);

    grid.setNoHeader(true);

    grid.setInitWidths("");

    grid.setColAlign(“left”);

    grid.setColTypes(“ed”);

    grid.init();

    grid.loadXML("/xml_comment.jsp?action=get_notes&rowId="+rowId+"&cellInd="+cellInd);

    dp = new dataProcessor("/xml_comment.jsp?action=update_notes&rowId="+rowId+"&cellInd="+cellInd);

    dp.setUpdateMode(“off”);

    dp.init(grid);

    dp.enableDebug(true);

    grid.setSkin(“customWin”);

}

else if(menuitemId == “showNotes”){

    

var w2 = dhxWins.createWindow(“w2”,0,0,200,200);

    w2.setText(“showNotes”);

    var grid = w2.attachGrid();

    grid.setImagePath("/images/imgs/");

    grid.setHeader(“Model”);

    grid.setNoHeader(true);

    grid.setInitWidths("
");

    grid.setColAlign(“left”);

    grid.setColTypes(“ro”);

    grid.init();

    grid.loadXML("/xml_comment.jsp?action=get_notes&rowId="+rowId+"&cellInd="+cellInd);    

}

else if(menuitemId == “deleteNotes”){



    dhtmlxAjax.get("/xml_comment.jsp?action=delete_notes&rowId="+rowId+“ampcellInd=”+cellInd);

}



return true;



}



function pre_function(rowId,cellInd,grid){



if(rowId%3!=2&&cellInd>1){

    var loader = dhtmlxAjax.getSync("/xml_comment.jsp?action=get_notes&gridname="+gridname+“amp;rowId=”+rowId+"&cellInd="+cellInd);

com = loader.xmlDoc.responseXML.documentElement.getElementsByTagName(“cell”)[0].childNodes[0].nodeValue;        

if (com == “no comment!”){

    menu.hideItem(“ms1”);

menu.hideItem(“showNotes”);

menu.hideItem(“ms2”);

menu.hideItem(“deleteNotes”);



}

else{

    menu.showItem(“addNotes”);

    menu.showItem(“ms1”);

    menu.showItem(“showNotes”);

    menu.showItem(“ms2”);

    menu.showItem(“deleteNotes”);     

}



return true;



}

return false;

}



function doInitGrid(){



menu = new dhtmlXMenuObject(null,“dhx_blue”);

menu.setImagePath("/otdassist/images/menu_imgs1/");

menu.setIconsPath("/otdassist/images/menu_imgs/");

menu.renderAsContextMenu();

menu.attachEvent(“onClick”,onButtonClick);

menu.loadXML("/codebase/_context2.xml");



mygrid = new dhtmlXGridObject(‘mygrid_container’);



mygrid.attachEvent(“onBeforeContextMenu”,pre_function);



}



Now, i have some problems:

1) In firefox after rightclick,i have my contextmenu but sometimes normal contextmenu from firefox is displayed at once.

2) After update a value in grid attached to window, when i close the window and open too, the old value will be shown until i update total the site.

3)Can i change the window’s icon?



Can you help me?

Thank you…

pyt





  1. In firefox after rightclick,i have my contextmenu but sometimes normal contextmenu from firefox is displayed at once.
    Issue can’t be reconstructed locally, you can try to add the next line of code
    dhtmlxEvent(“body”,“contextmenu”,function(){
    return false;
    });

    >>2) After update a value in grid attached to window
    In common case issue can be caused by XML caching.
    Please try to add
    grid.preventIECaching(true);

Issue can’t be reconstructed locally, you can try to add the next line of code
dhtmlxEvent(“body”,“contextmenu”,function(){
      return false;
});

I have used this lines in function “pre_function” above. But the contextmenu is total disabled. I would like disable only the contextmenu from browser.
Can you say me, what function and where exact should i use?
Thanks in advance!

You can try

dhtmlxEvent(mygrid.entBox,“contextmenu”,function(e){
(e||event).cancelBubble=true;
return false;
});

where mygrid - reference to the grid object