Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Ramakrishna on Jul 30, 2008 00:13
open dhtmlx forum
DHTMLX Grid : Show Context Menu for a particular CELL edit operation, Change CSS of Grid,

Hi there,
Can I have following things done in our grid, treegrid ?

1> Want to show right click context menu for A PARTICULAR CELL so that I can edit a cell only, not the whole row. Also, When I click on edit option of context menu for a cell, it should show the editbox directly instead of need to double click the cell to edit it.
2> How to attach image along with text shown on first column.
3> Also how to give color to whole column. Basically I want all columns except one to have white color and all rows to have white colors
except one.
Answer posted by Support on Jul 30, 2008 02:29
> Want to show right click context menu for A PARTICULAR CELL so that I can edit a cell only, not the whole row. Also, When I click on edit option of context menu for a cell, it should show the editbox directly instead of need to double click the cell to edit it.

You can conrol context menu by using onBeforeContextMenu event
    grid.attachEvent("onBeforeContextMenu",function(id,ind){
       if (ind == necessary_one ) return true;
       else return false;
    });
such code will allow context menu only for necessary column.
To initiate edit from menu command you can use defautl way to handle context menu commands and call selectCell and editCell against necessary cell.

>>How to attach image along with text shown on first column.
Technically , it possible to place any html as cell content
<row id="some">
    <cell><![CDATA[ <img src='some.gif'>  some text ]]></cell>

>>3> Also how to give color to whole column. Basically I want all columns except one to have white color and all rows to have white colors
    mygrid.setColumnColor("white,white,white,gray");  

Answer posted by Ramakrishna on Jul 30, 2008 06:35
Hi,
    Will the following code work for CELL(means any cell[Not Column] where I will right click to show context menu) ???
Answer posted by Support on Jul 30, 2008 10:04
Any cell in data part of grid ( not header ) will generate onBeforeContextMenu event before showing context menu. So code proposed above will work for any cell in  grid.
Answer posted on Aug 04, 2008 06:26
How can I attach image along with text shown by script not in XML file ?
How to show right click context menu for the cell on which I right click context menu ?
Answer posted by Support on Aug 04, 2008 07:24

>>How can I attach image along with text shown by script not in XML file ?
You can freely use HTML as cell values, when adding rows from js script
     grid.addRow(some_id,["a"," <img src='b.gif'> b text","c"]);

>>How to show right click context menu for the cell on which I right click context menu ?
If you are using dhtmlxmenu as context menu , you can use
          grid.enableContextMenu(obj);
In  case of custom menu , you can use onRightClick event

http://dhtmlx.com/docs/products/dhtmlxGrid/samples/context_menu/?un=1217861090000