Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by DJAY on Feb 05, 2010 10:08
open dhtmlx forum
How to read the option value of combo_v type cell in dhtmlxGrid

 

I am using dhtmlxGrid with one of the column cell types as combo_v. I am loding this grid through XML as below.

<?xml version="1.0" encoding="UTF-8"?>
<rows>

  <head>
  <column width="15" type="ro"  align="left" >Client Service Associates</column>
  <column width="22" type="combo_v" editable="true" align="left" xmlcontent="1">Role</column>
  
  <settings>
              <colwidth>%</colwidth>
         </settings>
       
 </head>
   
 <row id="row0" >
  <cell style="border-style: inset;border-width: 1px;">Max Loshinsky <BR/>CLIENT SERVICE ASSOCIATE</cell>  
  <cell type="combo_v" xmlcontent="1" style="border-style: inset;border-width:1px;">CLIENT SERVICE ASSOCIATE
          <option value="CSA">CLIENT SERVICE ASSOCIATE</option>
          <option value="FA">FINANCIAL ADVISOR</option>
          <option value="MAKTR">MARKETER</option>
     </cell>
  
 </row>

 <row id="row1" >
  <cell style="border-style: inset;border-width: 1px;">Chris Chen</cell>   

  <cell type="combo_v" xmlcontent="1" style="border-style: inset;border-width:1px;">CLIENT SERVICE ASSOCIATE
          <option value="CSA">CLIENT SERVICE ASSOCIATE</option>
          <option value="FA">FINANCIAL ADVISOR</option>
          <option value="MAKTR">MARKETER</option>
     </cell>

 </row>
<rows>

 

When I select some value  from combo and then read it using method  myGrid.cellById(rowId,1).getValue(); , it gives me the text that is currently deplayed on the drop down. e.g. CLIENT SERVICE ASSOCIATE, FINANCIAL ADVISOR or MARKETER

How do I get/read the value of the selected option.  e.g. CSA,FA, MAKTR

 

Answer posted by Alexandra on Feb 08, 2010 01:54
Hello,

you should use a value of some option as cell value to select this option:

 <cell type="combo_v" xmlcontent="1" style="border-style: inset;border-width:1px;">CSA

instead of

<cell type="combo_v" xmlcontent="1" style="border-style: inset;border-width:1px;">CLIENT SERVICE ASSOCIATE

Moreover if options are the same for all cell in the second column, it's better to define them in <column> tag:

<?xml version="1.0" encoding="UTF-8"?>
<rows>

   <head>
  <column width="15" type="ro"  align="left" >Client Service Associates</column>
  <column width="22" type="combo_v" editable="true" align="left" xmlcontent="1">Role<option value="CSA">CLIENT SERVICE ASSOCIATE</option><option value="FA">FINANCIAL ADVISOR</option><option value="MAKTR">MARKETER</option></column>
  <settings>
              <colwidth>%</colwidth>
         </settings>
       
 </head>
   
 <row id="row0" >
  <cell style="border-style: inset;border-width: 1px;">Max Loshinsky <BR/>CLIENT SERVICE ASSOCIATE</cell>  
  <cell style="border-style: inset;border-width:1px;">CSA</cell>
 </row>

 <row id="row1">
  <cell style="border-style: inset;border-width: 1px;">Chris Chen</cell>   

  <cell style="border-style: inset;border-width:1px;">CSA</cell>

 </row>
<rows>

PS: please ask questions on http://forum.dhtmlx.com/ or http://support.dhtmlx.com/







Answer posted on Feb 08, 2010 07:30

For my requirement, the option values and Cell values are different.  Option values are the codes coming from and going back to database while cell values are just text that will be displayed on the screen.

 Is it possible to read option values? How? 

Answer posted by Stanislav (support) on Feb 09, 2010 02:03
Grid linked to the combo options by key-to-key links. So grid must contains codes, and it will show labels by mapping those codes to the options of combo.