<script type="text/javascript">
var box1,box2;
$(function() {
//初始化8个listbox
box1 = $("#listbox1").ligerListBox({
isShowCheckBox: true,
isMultiSelect: true,
height: 140,
//发送给后台的请求
url: '${baseURL}/getDeviceByAll.action',
});
box2 = $("#listbox2").ligerListBox({
isShowCheckBox: true,
isMultiSelect: true,
height: 140,
});
var tempData2 = [{id:1,text:"aa"},{id:2,text:"bb"}];
//button点击事件
$("#btn1").click(function(){
setListBoxData(tempData2);
});
});
function setListBoxData(tempData2){
//貌似只能通过id来移除了 用removeItems不可以达到效果
//例如移除id为1,2的然后添加到左边
for(var i=0;i<tempData2.length;i++){
box1.removeItem(tempData2[i].id);
}
box2.addItems(tempData2);
}
//===========listbox四个按钮点击相关函数===========
function moveToLeft1()
{
var selecteds = box2.getSelectedItems();
if (!selecteds || !selecteds.length) return;
box2.removeItems(selecteds);
box1.addItems(selecteds);
}
function moveToRight1()
{
var selecteds = box1.getSelectedItems();
if (!selecteds || !selecteds.length) return;
box1.removeItems(selecteds);
box2.addItems(selecteds);
}
function moveAllToLeft1()
{
var selecteds = box2.data;
if (!selecteds || !selecteds.length) return;
box1.addItems(selecteds);
box2.removeItems(selecteds);
}
function moveAllToRight1()
{
var selecteds = box1.data;
if (!selecteds || !selecteds.length) return;
box2.addItems(selecteds);
box1.removeItems(selecteds);
}
</script>
<style type="text/css">
.middle input {
display: block;width:30px; margin:2px;
}
</style>
</head>
<body>
<div>
<div style="float:left;font-size:15px;width:150px;text-align: center">Support Devices:</div>
<div style="margin:4px;float:left;">
<div id="listbox1"></div>
</div>
<div style="margin:4px;float:left;" class="middle">
<input type="button" onclick="moveToLeft1()" value="<" />
<input type="button" onclick="moveToRight1()" value=">" />
<input type="button" onclick="moveAllToLeft1()" value="<<" />
<input type="button" onclick="moveAllToRight1()" value=">>" />
</div>
<div style="margin:4px;float:left;">
<div id="listbox2"></div>
</div>
</div>
<input type="button" value="点击" id="btn1">
</body>
private JSONArray jsonArray;
public JSONArray getJsonArray() {
return jsonArray;
}
public String getDeviceByAll() throws Exception{
List<Device> deviceList = deviceService.getAll(Device.class);
jsonArray = new JSONArray();
for(Device device:deviceList){
JSONObject obj = new JSONObject();
//listbox对应的数据格式要有text、id字段
obj.put("id",device.getDevId());
obj.put("text",device.getDevName());
jsonArray.add(obj);
}
return SUCCESS;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有