2010-12-09 147 views
0
<listbox id="lbx" rows="4"> 
    <listhead><listheader label="Name"></listheader><listheader label="Album"></listheader></listhead> 
    </listbox> 
public class page extends GenericForwardComposer{ 
    Combobox searchBox; 
    private Grid SuggestGrid; 

    private String q; 
    Button b; 
    Page p; 
    Label la; Listcell h,m; 
    protected Listbox lbx; // autowired 

    private ListModelList list,listq; // the model of the listbox 
    public void doAfterCompose(Component comp) throws Exception { 
     super.doAfterCompose(comp); 


     for(int i=0;i<=10;i++) 
     { 
      Listitem li = new Listitem(); 
      new Listcell("example").setParent(li); 
      new Listcell("google").setParent(li); 

      Label subTotalLb = new Label("$example "); 
      subTotalLb.setParent(li); 
      li.setParent(lbx); 
     } 


    } 

我可以在此列表单元格中只添加字符串。我的zkoss代码有什么问题?

为什么不能我加入这个按钮或标签....

+0

@The是文档精英绅士:老兄,你在编辑后离开“海”了吗? – JoseK 2010-12-09 09:46:43

回答

1

您可以在的ListCell创建自己的按钮

public void doAfterCompose(Component comp) throws Exception { 
    super.doAfterCompose(comp); 

    for(int i=0;i<=10;i++){ 
     Listitem li = new Listitem(); 
     Listcell lic = new ListCell(); 
     li.appendChild(lic); 
     Button myBtn = new Button("Btn"); 
     myBtn.setParent(lic); 

     //... 

    } 
} 

这里从zkoss.org Listboxes Contain Buttons