自动调整EasyUI combobox的panelHeight高度问题

在使用EasyUI的时候,有时会用到combobox组件,这里的记录数不是很固定,设置为auto可能会被挡住,设置固定高度时,option很少时,也很丑

所以这里给出我自己自动调整combobox的panelHeight的方法:

var orgCount = 0;
function initCombo() {
	$('#orgCombo').combobox({
		url: 'fetchOrgs.do', 
		valueField: 'id',
		textField: 'text',
		editable:false,
		onLoadSuccess: function(data){
			orgCount = data.length;
		},
		onShowPanel: function() {
			// 动态调整高度
			if (orgCount > 13) {
				$(this).combobox('panel').height(285);
			}
		}
	});
}


你可能感兴趣的:(web前端)