<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>xm-select测试demo</title>
<script src="xm-select.js"></script>
<script src="jquery-1.10.2.min.js"></script>
</head>
<body>
<h3>xm-select测试demo</h3>
<div id="select_value_id">已选中值:0</div>
<div id="selectDemo" class="xm-select-demo" style="width: 500px;"></div>
</body>
<script src="xm-select.js"></script>
<script>
xmSelect.render({
el: '#selectDemo',
checkbox: true,
repeat: false,
autoRow: true,
filterable: true,
prop: {name: 'name', value: 'value',selected:'selected'},
height: '200px',
tips: '请选择',
tree: {
show: true,
showFolderIcon: true,
showLine: true,
indent: 20,
expandedKeys: [-3],
strict: false,
},
data: function () {
return [{name:'张三',value:'0',selected:true},{name:'李四',value:'1'},{name:'王五',value:'2'},{name:'赵六',value:'3'},{name:'张奇',value:'4'},{name:'王八',value:'5'}];
},
on: function (data) {
var arr = data.arr;//arr: 为已选中的值
console.log(data)
var selected_value = '';
//arr: 当前多选已选中的数据
$.each(data.arr, function(i, item) {
selected_value += item.value + ',';
})
if(selected_value != '') {
selected_value = selected_value.substring(0, selected_value.length - 1);
}
$("#select_value_id").text('已选中值:' + selected_value);
},
});
</script>
</html>
评论10