Select Box default selected

I am currently using the pro version of dhtmlxgrid.

I am using the “Initialization from XML - For separate cell” method for initializing my select box collection. This method is mentioned in the link below:
http://docs.dhtmlx.com/doku.php?id=dhtmlxgrid:initialization_from_xml

The select box is being populated properly.

But I want a particular list box element to be selected by default.
For Eg: If I populate the list with elements [1,2,3,4,5,6,7,8,9,10] in the same order.
Then I want item “5” to be selected, when the grid is displayed the first time.
How can I achieve this?

You should pass option id as cell value
docs.dhtmlx.com/doku.php?id=dhtm … from_xml&s[]=select&s[]=box

Thanks for the reply.

I tried this, but could not get it properly. The option id you pass as the cell value, is being treated as another item in the list. This is not what I want. After I populate the list, i want a item from that list to be selected.

Here is what i am doing:

<cell xmlcontent="true">
      2010
       <option value="2009">Year 2009</option>
       <option value="2010">Year 2010</option>
       <option value="2011">Year 2011</option>
</cell>

After doing the above, I should have 3 items in the list, and “Year 2010” should be selected.
But what I get is, 4 items in the list, with “2010” as the last item.

Please help.

Thanks

You should not use bland spaces and new line between cell value and tag:

<cell type="co" xmlcontent="true">2010<option value="2009">Year 2009</option> <option value="2010">Year 2010</option> <option value="2011">Year 2011</option> </cell>

This worked!! :smiley: :smiley:

The bland spaces/new line were the problem.

Thanks a lot,Olga. You saved me a lot of time. :smiley:

Hi all, I have a similar issue, Im trying, to set selected item.
Is there a method to do that from js??.
I am using the “Initialization from js loadXMLString event, where I load the select box for each cell of the 2nd column, for each row .
I would like to choose the selected item on edit event but I dont know which method I should use.
The column type is “coro”.

Thanks anyway