:: Forum >>

CheckedList (onItemClicked) - How do i know if item is(was) selected or not?

Example:
var checked = new AW.UI.CheckedList;
    checked.onItemClicked = function(event, i){
// i is selected, will turn selected or what?
}
Paulo Cesar Silva Reis (PC from Brazil).
Tuesday, April 25, 2006
In this case i is an item index. Might be easier using other events -

Individual item selection state - true/false

obj.onItemSelectedChanged = function(value, index){
alert(value + " " + index);
}

or array of all selected items

obj.onSelectedItemsChanged = function(values){
alert(values);
}
Alex (ActiveWidgets)
Wednesday, April 26, 2006
Nice, tkz.
Paulo Cesar Silva Reis (PC from Brazil).
Thursday, April 27, 2006
Am I correct that onItemSelectedChanged fires twice for a AW.UI.Combo? The old value is held by <index> when <value> is false?
Paul Tiseo
Friday, April 28, 2006
Not sure about combo, but with lists in general, yes, one item selection state changes from true to false (unselected) and another one from false to true (the one being selected) so onItemSelectedChanged event fires twice.

Also for each of them there is onItemSelectedChanging event which fires before change.

And also there is an array of selected items, which has its own change events - onSelectedItemsChanging/Changed.
Alex (ActiveWidgets)
Friday, April 28, 2006
Can you abort the change with onItemSelectedChanging() if you return 1, like with onCellValidating()?
Paul Tiseo
Monday, May 1, 2006
I'll add that I've tried and it apparently doesn't work that (hoped for) way. In fact, onItemSelectedChanging() and onItemSelectedChanged() seem to both return the same index based on the true/false of the value argument. They only differ on the timeing of when they are called?

var feeCombo = new AW.UI.Combo();
feeCombo.setId("feeCombo");
feeCombo.setItemCount(myFeesVals.length);
feeCombo.setItemText(myFeesVals);
feeCombo.setItemValue(myFeesKeys);
feeCombo.defineItemProperty("color", myFeesClrs);
feeCombo.getItemTemplate().setStyle("color", function(){
    if (this.getItemProperty("color") == "noshow")
        return "red";
    else
        return "black";
});
// make combo more <select>-like
feeCombo.getContent("box/text").setAttribute("readonly", true);
feeCombo.onControlEditStarted = function() {
    this.getContent("box/text").element().contentEditable = false;
};
feeCombo.onItemSelectedChanging = function(value, index) {
    if ( value ) {
        if( myFeesClrs[index] == "noshow" )
            return 1;
    }
}
Paul Tiseo
Monday, May 1, 2006

This topic is archived.


Back to support forum

Forum search