Zk 中 两列 listbox资料转移,并获得 listbox中的值

本文介绍了一个Java页面中处理列表选择与数据交互的方法。主要包括从候选列表中选择项目并移动到已选列表,以及从已选列表移除项目返回到候选列表的功能实现。文章还展示了如何通过SQL查询填充列表,并提供了获取已选项目数量和具体信息的示例代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<hlayout height="160px"  width="260px">
    <listbox id="candidateLb" hflex="1" vflex="true" multiple="true" rows="8">
        <listhead>
            <listheader label="合同成品" width="80px" ></listheader>
        </listhead>
        
    </listbox>
    
    <vbox spacing="10px" width="24px">
        <image style="cursor:pointer" id="chooseAllBtn" src="/img/rightrightarrow_g.png" />
        <image style="cursor:pointer" id="chooseBtn" src="/img/rightarrow_g.png" />
        <image style="cursor:pointer" id="removeBtn" src="/img/leftarrow_g.png" />
        <image style="cursor:pointer" id="removeAllBtn" src="/img/leftleftarrow_g.png" />
    </vbox>
         
      <listbox id="chosenLb" hflex="1" vflex="true" multiple="true" rows="8">
        <listhead>
            <listheader label="已選成品" width="80px"></listheader>
        </listhead>
        <template name="model">
            <listitem>
            </listitem>
        </template>
      </listbox>
   </hlayout>




java页面处理


	public void onClick$chooseBtn() throws Exception{
		if(candidateLb.getSelectedIndex()<0) {
			MyMessagebox.info("請選中合同成品資料.");
			return;
		}
		String files=this.candidateLb.getSelectedItem().getValue();
		candidateLb.removeItemAt(candidateLb.getSelectedIndex());
		chosenLb.appendItem(files,files);
	}
	public void onClick$removeBtn() throws Exception{
		if(chosenLb.getSelectedIndex()<0){
			MyMessagebox.info("請選中已選成品資料.");
			return;
		}
		String files=this.chosenLb.getSelectedItem().getValue();
		chosenLb.removeItemAt(chosenLb.getSelectedIndex());
		candidateLb.appendItem(files,files);
	}
	public void onClick$chooseAllBtn() throws Exception{
		if(lstcontractno.getSelectedIndex()<0) return;
		chosenLb.getItems().clear();
		String parax=lstcontractno.getSelectedItem().getValue().toString().toUpperCase();
		JdbcDao dao=JdbcFactory.getDgWofeJdbcDao(plant);
		String sql=" select sequenceno||'.'||itemno as consumelst  from ct_t_contractitem  where class='0' AND contractid='"+parax+"'";
		ArrayList<LinkedHashMap> lstRet=  dao.query(sql);
		for(LinkedHashMap map: lstRet){	
			chosenLb.appendItem((String)map.get("CONSUMELST"),(String)map.get("CONSUMELST"));
		}	
		candidateLb.getItems().clear();
	}
	public void onClick$removeAllBtn() throws Exception{
		onSelect$lstcontractno();  //查询出来的所有资料
		chosenLb.getItems().clear();
		
	}

获得已选资料的笔数  this.chosenLb.getItems().size();


获得已选资料  (因我的资料是两个栏位合成,所有有进行字符截取)

 String sequence_no="",item_no="";
List<Listitem> list = this.chosenLb.getItems();  
if(list != null){
int index = 0;
double c =  ((double) list.size())/5;
index=(int) Math.ceil(c);
 
for(int i = 0; i < list.size(); i++){
String itemx = list.get(i).getValue();
String a[] = itemx.split("\\.");  //截取字符串
     if(i < list.size()-1){
        sequence_no+="'"+a[0]+"',";
        item_no+="'"+a[1]+"',";
     }else{
       sequence_no+="'"+a[0]+"'";
       item_no+="'"+a[1]+"'";
      }
      }
         }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值