Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by c. bernstein on Jan 18, 2010 09:41
open dhtmlx forum
Grid with combo box in only specific cells

I have a column in a grid that I want to use a select box with four values (1,2,3,4). Is there a way to only display the select box if a different column in the grid is filled in? For instance, if there are ten rows in the grid, but only two of them have a column filled in, I only want those two rows to display the combo box select with the (1,2,3,4).

Thanks!
Chava
Answer posted by Alex (support) on Jan 19, 2010 06:39

There are two possible solutions:

1) the column type is coro, the options are defined for the column:

var combo = grid.getCombo(index)

combo.put(key1,value1);

..

combo.put(keyN,valuen);

But 8 from 10 rows have another type:

<cell type="ro">...</cell>

Or you can use setCellExcellType method to define cell type.

2) column type isn't coro, but  2 cells in this column have coro type:

<cell type="coro" xmlcontent="1">1<option value="1">some text here</option><option value="2">...</option></cell>

Answer posted on Jan 19, 2010 06:47
If I use setCellExcelType() to define a cell with type coro, how do I set the option list?
Answer posted by Alex (support) on Jan 19, 2010 07:42

var combo = grid.getCustomCombo(rowId,columnIndex);

combo.put(key,value);

Answer posted on Jan 20, 2010 07:16

I am doing the following and it is not working:

grid.setCellExcellType(rowId, 10, "coro");
         var c = grid.getCustomCombo(rowId, 10);        
         c.put("A", 1);
         c.put("B", 2);
         c.put("C", 3);
         c.put("D", 4);

Is there something else I need to be doing?

Thanks in advance.

Answer posted by Alex (support) on Jan 20, 2010 08:53

The provided code looks correct. It should be called when row is loaded/added. In case of xml loading:

grid.loadXML(url,function(){

  grid.setCellExcellType(rowId, 10, "coro");
  var c = grid.getCustomCombo(rowId, 10);  
  c.put("A", 1);
  c.put("B", 2);
  c.put("C", 3);
  c.put("D", 4);

})

To change cell value you can use setValue method:

grid.cells(rowId, 10).setValue("A");

Answer posted on Jan 20, 2010 09:06

I am doing just that, I think, and it's not working.  I am not seeing the combo box that is defined in the grid:

grid.load(myUrl, function () {        

myGrid.setCellExcellType(rowId, 10, "coro");
         var c = myGrid.getCustomCombo(rowId, 10);        
         c.put("A", 1);
         c.put("B", 2);
         c.put("C", 3);
         c.put("D", 4);

}

Answer posted by Alex (support) on Jan 21, 2010 04:01

Drop-down appears only in editing mode. When cell isn;t edited, you see cell value. 

Please provide complete sample to recreate the problem if the editor type  isn't set.