DHTMLX Docs & Samples Explorer

Index
dhtmlxgrid

## How to Use New Excell “Combo”

“combo” excell uses dhtmlXCombo as the editor and supports all modes of this component.

There are two ways of setting a combo:

1) For the whole column;

2) For a certain cell.

Combo loading and representation modes are set by special attributes in the xml:

a) xmlcontent - In this case the options can be defined directly in the grid xml;

b) source - Sets the source of the combo xml;

c) editable - true/false; “true” by default;

d) filtering - true/false; “false” by default. Enables filtering mode (the same as enableFilteringMode for the combo);

e) auto - true/false; “false” by default. Enables autocomplete mode (the same as enableFilteringMode(mode,source) for the combo);

- cache (the additional parameter for autocomplete mode) – the xml suggestions are cached (the same as enableFilteringMode(mode,source,cache));

- sub (the additional parameter for autocomplete mode) - enables auto load additional suggestions on selecting the last loaded option (the same as enableFilteringMode(mode,source,cache,sub)).

Setting “combo” column:

For the whole column the combo is set in the <column> tag.

Examples:

      <column width="150" type="combo" xmlcontent="1" …>TEXT<option value="1">one</option>
        <option value="2">two</option>
        <option value="3">three</option>
        …
      </column>
      <column width="150" type="combo" editable="false" source="data.xml" …>TEXT</column>
      <column type="combo" source="complete.php" auto="true" cache="true" sub="true"… >TEXT</column>

Combo value should be set inside the <cell> tags:

      <cell>1</cell>

In case of autocomplete mode the following instruction defines the value and the text:

      <cell>value^text</cell>

For example:

      <cell>1^one</cell>

Setting “combo” cell:

The combo for a cell is set practically in the same way as one for the column. The difference is in using the <cell> tag instead of the <column> one. Also the xmlcontent attribute is always necessary:

      <cell xmlcontent="1" editable="0">1<option value="1">one</option>
        <option value="2">two</option>
        <option value="3">three</option>
      </cell>
      <cell xmlcontent="1" source="data.xml" filter="true”>1</cell>

In case of autocomplete mode the text should be set with the help of the text attribute:

      <cell xmlcontent="1" source="complete.php" auto="true" cache="true" text="some text">4</cell>

Methods:

getCellCombo() returns cell combo object:

      combo = grid.cells(rowId,cellIndex).getCellCombo();

      combo.addOption(key,text);

getColumnCombo(columnIndex) returns column combo object:

      grid = new dhtmlXGridObject('gridbox');
      ...
      grid.setColTypes("...,combo,...");
      grid.init();

      combo = grid.getColumnCombo(columnIndex);

      combo.enableFilteingMode(true);
      combo.loadXML("data.xml");