0

foreach or model

asked 2009-08-28 02:21:06 +0800

mmghp30 gravatar image mmghp30
70 1

hi
i write this code to convert a foreach to setmodel in fact in this code i set model a list of class
that have some variable now you can use it for this job but have a problem ;
when i use it in a listbox the label of each listcell is wrong while i set it in line 15;
what is your opinion ?

     <listbox id="libo1" rows="10" width="350px" height="300px" >
	<listhead sizable="true">
                                         <listheader  width="15%" label="labela" />
	</listhead>

                                    </listbox>
                                    <zscript>

List mast=asa.selectAll(1);
ListModel stot = new SimpleListModel(mast);
libo1.setModel(stot);
for(int ij=1;ij<libo1.getChildren().size();ij++)
{
    Listitem assa=(Listitem)libo1.getChildren().get(ij);
    Listcell assb=(Listcell)assa.getFirstChild();
    salam bis=(salam) libo1.getListModel().getElementAt(ij-1);
    assb.setLabel(bis.name);
    assa.addEventListener("onClick",new EventListener() {
    public void onEvent(Event event) throws Exception {
    yselected=(asatid) libo1.getListModel().getElementAt(libo1.getSelectedIndex());
    //alert(yselected.id);
    // assb.setLabel(bis.name);
    alert(yselected.name);
    alert(yselected.date);
    }
});

}
</zscript>

delete flag offensive retag edit
Be the first one to reply this discussion!
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-08-28 02:21:06 +0800

Seen: 158 times

Last updated: Aug 28 '09

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More