Contextmenu

Hi,



I am trying to put a context menu on a grid. In the gridExport function I want to check if the Item is printview the do

gridObject.printView(); else do the other.



function gridExport(gridObject)

{

    gridObject.printView();

var html="";

var numRows=gridObject.getRowsNum();

var numCols=gridObject.getColumnsNum();

html=html+"

";

//this for loop is used for column lable

     for(k=0;k<=numRows-1;k++)

         {

for(c=0;c<numCols;c++)

        {

        if(typeof gridObject.hdr.rows[(k||0)+1]!=‘undefined’&&gridObject.getColumnLabel(c,k)!=null){

        html=html+"";

}

}

    html=html+"";

     }

    //this for loop is used for data on grid

for(i=1;i<=numRows+1;i++)

{ html=html+"";

for(j=0;j<numCols;j++)

{

html=html+"";

}

html=html+"";

}

html=html+"
"+gridObject.getColumnLabel(c,k)+"
";

var txt="";

if(gridObject.getRowById(i)!=null&&typeof gridObject.cells(i,j)!=‘undefined’&&gridObject.cells(i,j).getValue()!=null)

                {    //alert(gridObject.cells(i,j).getValue().toString().split("^")[0].substring(0,4))

                    if(gridObject.cells(i,j).getValue().toString().split("^")[0].substring(0,4)!="<img")

                    txt=gridObject.cells(i,j).getValue().toString().split("^")[0];

                

                }

                 html=html+txt+"
";

document.summary.csvBuffer.value=html;

document.summary.method=‘POST’;

document.summary.action=contextURI+‘jsp/ExportToExcel.jsp’;

document.summary.target=’_blank’;

document.summary.submit();

return;

}







function getMenu(loadDataParam)

{

var menu = new dhtmlXMenuObject(null,“standard”);

    menu.setImagePath(uri+“dhtmlxMenu/codebase/imgs/”);

    menu.setIconsPath(uri+“dhtmlxMenu/images/”);

    menu.renderAsContextMenu();

    menu.setOpenMode(“web”);



    var menu_content="<?xml version='1.0' ?><menu id=“0”><item text=“Export To Excel” id=“edit_Red”/><item text=“Print Preview” id=“print_Red”/>";

    menu.attachEvent(“onClick”,function(){gridExport(loadDataParam.dataGridObject);});

    menu.loadXMLString(menu_content);

loadDataParam.dataGridObject.enableContextMenu(menu);

}





Thanks

Joe


Hello,


onClick menu handler gets id of clicked menu item.


menu.attachEvent(“onClick”,function(itemId){if(itemId == “printview”) gridExport(loadDataParam.dataGridObject);});