Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Daniel on Jul 27, 2009 18:20
open dhtmlx forum
ComboBox in Grid - getComboText returning empty string

Hi.

I have a grid and want to populate combos when the user types into them. I am able to return a combobox object, however when I use the the getComboText, it is not showing the text I have typed into the combobox. I have included some code snippet to demo what I am doing. I hope it helps. Please let me know if you have any additional questions.


<code>
function doInit(){
parentGrid.setHeader("COMMITMENT_PK,Type,Number,Title,VENDOR_FK,AMOUNT,STATUS_DOM,JOAN_FK,PROGRAM_AMENDMENT_FK,IS_DELETED,AGENDA_ITEM_ID_FK,FEG_FK,IS_UNION_REQUIRED,PUBLIC_WORKS_NUMBER,CREATED_BY,CREATED_DATE,LAST_UPDATED_BY,LAST_UPDATED_DATE"); parentGrid.setInitWidths("0,150,75,200,100,100,100,100,100,100,100,100,100,100,100,100,100,100");
parentGrid.setColAlign("left,left,left,left,left,right,left,left,left,left,left,left,left,left,left,left,left,left");
        parentGrid.setColumnsVisibility("true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false");
parentGrid.setColTypes("ro,combo,ed,ed,combo,price,ed,ed,ed,ed,ed,ed,ed,ed,ed,ed,ed,ed");
parentGrid.init();
parentGrid.parse(cfGridXML,"xml");
parentGrid.selectRow(0, false, false, true);

comboVendor = parentGrid.getColumnCombo(4); //commitment vendor
comboVendor.attachEvent("onKeyPressed",checkVendorList);


}

    function checkVendorList(){
        var vendorCombo = parentGrid.cells(parentGrid.getSelectedRowId(),4).getCellCombo();
        alert(vendorCombo.getComboText());
    }
</code>


Thank you in Advance for your help.

BTW: We are loving the product so far!!
Answer posted by dhxSupport on Jul 28, 2009 00:54
To get text which user was types at the combo box better to use "onEditCell" event:
mygrid.attachEvent("onEditCell",function(stage,rowId,cellIndex,newValue,oldValue){
if (stage==2){
 if (cellIndex==0){
  var combo=mygrid.cells(rowId,cellIndex).getCellCombo()
  var text=combo.getComboText();
  alert(text);
 }
return true;
}
return true;
})

Answer posted by Daniel on Jul 28, 2009 07:44
Well, I am hoping to create Auto Suggest functionality. So, as the user types into the field, I would like to populate options from an ajax call. Using OnEditCell doesn't allow me to check for OnKeyPressed. When I add the OnKeyPressed event to the Combo, I am able to get the combo object for the cell. So, I can see the getComboText() function. However, when I call it it returns blank text.
Answer posted by Alex (support) on Jul 28, 2009 09:32

Hello, 

autocomplete functionality is already implemented for dhtmlxCombo. So, you don't need to create it: http://dhtmlx.com/docs/products/dhtmlxCombo/samples/filtering/combo_filter.html?un=1248799237000

Please, see details in the following post:

http://dhtmlx.com/docs/products/kb/index.php?s=normal&q=10764