3.2.0

Combos in Grid change simultaneously

Hello, I have a grid with combo boxes in the first column. When I change the value of a combo box in one cell, then select a new value for a combo box in another cell, the text value of the previous combo box reverts back to its original value. I am using the code that Alex provided except for one small change. I have to call grid.refresh() at the end, otherwise the text values in my combo boxes will not change at all. I am using the following code:

comboText[<%=i%>] = "<%=goals[i].getLongNm()%>";
comboValue[<%=i%>] = "<%=goals[i].getGoalId()%>";
obj.setCellTemplate(new AW.Templates.Combo, 0);
obj.setPopupTemplate(function(col,row){
var grid = this;
var list = new AW.UI.List;
list.setItemText(comboText);
list.setItemValue(comboValue); list.setItemCount(<%=goals.length%>); list.onItemClicked=function(event, index){
var value = this.getItemValue(index);
var mytext = this.getItemText(index); grid.setCellText(mytext,col,row);
grid.setCellValue(value,col,row);
grid.getCellTemplate(col,row).hidePopup();
grid.refresh();

}
return list;
});

This is obviously not all of the code I use to create the grid, but just the section I am having difficulty with. I have to use this format because I have to set the cell value to be different than the cell text. The default popup template does not allow me to change the cell value, just the cell text. Any thoughts on this problem?
Dean
February 21,
I just checked, this only occurs in Firefox, IE works fine but i need to use Firefox.
Dean
February 21,
Seriously, this is a problem in Firefox can anyone help?!!
Dean
February 21,
Sorry for that. AW popup/combo code desperately requires good re-design :-(

For now I can suggest the following solution -

var list = new AW.UI.List;
list.setItemText("item");
list.setItemValue("value");
list.setItemCount(10);

var obj = new AW.UI.Grid;
obj.setCellData("cell");
obj.setColumnCount(10);
obj.setRowCount(10);

obj.setCellTemplate(new AW.Templates.Combo, 0);
obj.setPopupTemplate(list);

// should be after setPopupTemplate(list)
list.onItemClicked = function(event, index){

    var col = this.$0;
    var row = this.$1;

    var value = this.getItemValue(index);
    var text = this.getItemText(index);

    obj.setCellText(text, col, row);
    obj.setCellValue(value, col, row);

    AW.$popup.hidePopup();

    var e = obj.getCellTemplate(col, row).getContent("box/text");

    if (AW.ie) {
        e.innerHTML = text;
    }
    else {
        e.value = text;
    }
}

document.write(obj);


You should put list.onItemClicked = function... statement after obj.setPopupTemplate(list) because setPopupTemplate method assigns its own onItemClicked handler to the list :-(

Alex (ActiveWidgets)
February 21,

This topic is archived.

See also:


Back to support forum