• easyui-combox(tagbox) 多选操作 显示为tagbox


    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <link rel="stylesheet" type="text/css" href="./common-static/css/themes/default/easyui.css">
        <link rel="stylesheet" type="text/css" href="./common-static/css/themes/icon.css">
    </head>
    <body>
    
    <input id="tb" type="text" style="300px"> 
    
    <script src="./common-static/js/jquery.min.js"></script>
    <script src="./common-static/js/jquery.easyui.min.js"></script>
    <script src="./common-static/js/easyui-lang-zh_CN.js"></script>
    
    <script>
    	$('#tb').combobox({    
    		valueField: 'id',    
    		textField: 'text',    
    		data: [{    
    				"id":1,    
    				"text":"text1" 
    			},{    
    				"id":2,    
    				"text":"text2",
    				"selected":true  
    			},{    
    				"id":3,    
    				"text":"text3",
    				"selected":true 
    			},{    
    				"id":4,    
    				"text":"text4"   
    			},{    
    				"id":5,    
    				"text":"text5"   
    			}],
                multiple:true,
    			hasDownArrow:true,
    			editable:false,
    			separator:' , ',
    		formatter: function (row) {
                var opts = $(this).combobox('options');
                return '<input type="checkbox" class="combobox-checkbox">' + row[opts.textField]
            },
    
            onShowPanel: function () {
                var opts = $(this).combobox('options');
                var target = this;
                var values = $(target).combobox('getValues');
                $.map(values, function (value) {
                    var el = opts.finder.getEl(target, value);
                    el.find('input.combobox-checkbox')._propAttr('checked', true);
                })
            },
            onLoadSuccess: function () {
                var opts = $(this).combobox('options');
                var target = this;
                var values = $(target).combobox('getValues');
                $.map(values, function (value) {
                    var el = opts.finder.getEl(target, value);
                    el.find('input.combobox-checkbox')._propAttr('checked', true);
                })
            },
            onSelect: function (row) {
                var opts = $(this).combobox('options');
                var el = opts.finder.getEl(this, row[opts.valueField]);
                el.find('input.combobox-checkbox')._propAttr('checked', true);
            },
            onUnselect: function (row) {
            	
                var opts = $(this).combobox('options');
                var el = opts.finder.getEl(this, row[opts.valueField]);
                el.find('input.combobox-checkbox')._propAttr('checked', false);
            }
    	})
    </script>
    </body>
    </html>
    

      

  • 相关阅读:
    [Linux] 解决CentOS下Requires: libjson-c.so错误
    磁盘分区就是这么简单,电脑小白都能看懂的磁盘分区教程!
    Linux常见压缩、解压缩
    安装/删除MySQL数据库
    MapReduce与Yarn 的详细工作流程分析
    SQL 增、删、改、查语句
    Apache Kylin 概述
    DHCP服务器配置及测试
    忘记root密码
    记第一次重装系统
  • 原文地址:https://www.cnblogs.com/hfultrastrong/p/9887937.html
Copyright © 2020-2023  润新知