Categories | Question details Back To List | ||
combo set up as cell editor - how to select default option? var dgrid = new dhtmlXGridObject('devGrid'); dgrid.setImagePath("../codebase/imgs/"); dgrid.setHeader("Name, Value"); dgrid.setInitWidths("*, 100"); dgrid.setColAlign("left, center"); dgrid.setSkin("light"); dgrid.setColSorting("na,na"); dgrid.setColTypes("ro,ro"); dgrid.enableDragAndDrop(true); dgrid.init(); dgrid.loadXMLString("<rows><row id='device_name'><cell>Name</cell><cell type='ed'></cell></row><row id='direct_processor_1'><cell>Direct Processor 1</cell>"+ "<cell type='combo' xmlcontent='true'><option value='not_set' selected='true'>not set</option><option value='pr1'>proc 1</option></cell></row></rows>"); dgrid.attachEvent("onXLE",function(){ var combo = dgrid.cells('direct_processor_1',1).getCellCombo(); combo.readonly(true); combo.selectOption(1); // index //combo.setComboValue("not_set"); //value }); Answer posted by Alex (support) on Jun 30, 2009 07:12 Hello, the value should be set in grid. So, the xml string can be: dgrid.loadXMLString("<rows><row id='device_name'><cell>Name</cell><cell type='ed'></cell></row><row id='direct_processor_1'><cell>Direct Processor 1</cell>"+ The event handler can be deleted: //dgrid.attachEvent("onXLE",function(){...}) Answer posted by Kathy on Jun 30, 2009 08:42 This way the option appears as selected, but combo.getSelectedValue() returns null and combo.getSelectedIndex() returns -1, so evidently combo box is not really 'selectiong' that option. Let me ask the question differently, - is there a way to programmatically select an option in combo box used as a cell editor? Documentation specifies 2 methods below, but none of them have any effect on my combo! Please, help. combo.selectOption(0); // index combo.setComboValue("not_set"); //value Answer posted by Alex (support) on Jun 30, 2009 09:05 In case of combo excell only grid methods can be use to set and get cell (combo) value: grid.cells(rowId,cellIndex).setValue(value); var value = grid.cells(rowId,cellIndex).getValue(); Answer posted by Kathy on Jun 30, 2009 09:26 Thank you! That works!! |