3.2.0

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).
April 25,
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)
April 26,
Nice, tkz.
Paulo Cesar Silva Reis (PC from Brazil).
April 27,
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
April 28,
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)
April 28,
Can you abort the change with onItemSelectedChanging() if you return 1, like with onCellValidating()?
Paul Tiseo
May 1,
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
May 1,

This topic is archived.

See also:


Back to support forum