3.2.0

Combo Popup not closing on selected value

Alex...

For some reason the popup will not close even when the combo loses focus. Is there something I'm missing here.

I included the function I use for generating the grid. It will close if I actually click off the popup but not on the selecting of a value.

// Grid object
var col = ["","id","Benchmark","Value"];
var colFormat = [str,str,num];
var colData = ["","@id","@bm","@value"];
var colIndices = [0,2,3];
var colCount = 4;
var rowCount = 0;

step3Grid_ = gridControlFromXml("step3Grid_","xmlIsland","//bms",col,colFormat,colData,colIndices,colCount,null,true,ckDeletedColumn);

//
function dynamicXmlTable(xml,columnData){
try{
var table = new AW.XML.Table;
table.setColumns(columnData);
table.setXML(xml);

return table;
}catch(e){alert("dynamic table xml: " + e.message);}
}
//
function gridControlFromXml(gridName,xmlName,xpath,columns,columnFormat,columnData,columnIndices,columnCount,rowCounter,bCkFirstColumn,ckFunction){
try{
var obj = new AW.Grid.Extended;
var xml = window.document.getElementById(xmlName);

// define data formats
var str = new AW.Formats.String;
var num = new AW.Formats.Number;

obj.setId(gridName);
obj.setColumnCount(columnCount);

if(rowCounter==null){
obj.setRowCount((xml.selectSingleNode(xpath).childNodes.length!=null) ? xml.selectSingleNode(xpath).childNodes.length : 0);
}else{
obj.setRowCount(rowCounter);
}

obj.setColumnIndices(columnIndices);

// provide column labels
obj.setHeaderText(columns);
// set cell format
obj.setCellFormat(columnFormat);
// provide external model as a grid data source
obj.setCellModel(dynamicXmlTable(xml,columnData));

// Widths
obj.setColumnWidth(225, 2);
obj.setColumnWidth(65, 3);
obj.setStyle("width","100%");

//bCkFirstColumn Add checkbox
if(bCkFirstColumn){
var ck = new AW.Templates.Checkbox;
ck.setStyle("border", "solid 1px #E5E8EB");
ck.setStyle("padding-right", "1px");
obj.setCellTemplate(ck, 0);
obj.getCellTemplate(0).refresh();

obj.setCellValue(false, 0);
obj.setColumnWidth(20, 0);
obj.setCellText(function(col, row){return this.getCellValue(col, row) ? "yes" : "no"}, 0);
}

// BEGIN COMBO POPUP CODE
rowCombo = new AW.Templates.Combo;
rowCombo.setStyle("border", "solid 1px #E5E8EB");
obj.setCellTemplate(rowCombo, 2);
obj.getCellTemplate(2).refresh();

obj.setPopupTemplate(function(col, row){
var grid = this;
var docList = new AW.UI.List;
var values = ["VWAP","TWAP", "Open","MOC"];
docList.setItemText(values );
docList.setItemCount(4);

docList.onItemClicked = function(event, i){
var text = this.getItemText(i);
grid.setCellText(text, col, row);
grid.setCellValue(text, col, row);

this.getCellTemplate(col, row).hidePopup();
grid.setCurrentColumn(3);
grid.setSelectedColumns([3]);
grid.raiseEvent("editCurrentCell");
}

docList.setSize(step3Grid_.getColumnWidth(col), 70);
return docList;
});


// set the border for all cells
obj.getCellTemplate().setStyle("border", "solid 1px #E5E8EB");

//Virtual Mode
obj.setVirtualMode(false);

// Set editable
obj.setCellEditable(false);
obj.setCellEditable(true,3);

function triplets(){
return this.getRowProperty("position") % 6 == 0 ||
this.getRowProperty("position") % 6 == 1 ||
this.getRowProperty("position") % 6 == 2 ? "even" : "odd";
}

obj.getRowTemplate().setClass("alternate", triplets);
obj.getRowTemplate().setClass("mouseover", "#ffff80");

obj.setController("myTabKeys", {
onKeyTab: "selectNextCell",
onKeyShiftTab: "selectPreviousCell"
}
);

obj.onCellSelectedChanged = function(selected, col, row){
if (selected){
this.setTimeout(function(){
this.raiseEvent("editCurrentCell", {}, col, row);
});
}
}

obj.onRowAdded = function(row){
try{
obj.setCurrentRow(row);
this.setCellText("new", 0, row);
this.setCellText(row, 1, row);
//this.setCellText("0", 4, row);
window.setTimeout(function(){
obj.setCurrentColumn(2);
obj.setSelectedColumns([2]);
}, 300 );
obj.setCurrentColumn(2);
obj.setSelectedColumns([2]);
obj.raiseEvent("editCurrentCell");
}catch(e){}
}

return obj;
}catch(e){
alert(e.message);
}
}
Mike B
November 8,
Looks like docList.onItemClicked function does something wrong. I am not sure you actually need it - the combo template should work without it.

It seems that you need 'grid' instead of 'this' in the following line -
this.getCellTemplate(col, row).hidePopup();
Alex (ActiveWidgets)
November 9,

This topic is archived.

See also:


Back to support forum