当前位置 博文首页 > zcy_wxy的博客:easyui-combobox 下拉列表排序

    zcy_wxy的博客:easyui-combobox 下拉列表排序

    作者:[db:作者] 时间:2021-07-21 21:38

    ?代码中loadFilter部分,为排序的主要内容

    $('#xxx').combobox({
    	url: xxx,
    	valueField: 'xx',
    	textField: 'xxx',
    	panelHeight: 'auto',
    	width : 150,
    	height : 20,
    	editable: false,
    	loadFilter: function(data){
                    //此处data为数组,核心是数组的sort方法
    		data.sort(function (a, b) {
    			return a.xxxx>b.xxxx;
    		})
    		return data;
    	},
    	onShowPanel : function(){
    		var count = $(this).combobox('getData').length;
    		if(count > 10){
    			$(this).combobox('panel').height(180);
    		}else{
    			$(this).combobox('panel').height("auto");
    		}
    	}
    });

    cs
    下一篇:没有了