easyui combobox模糊匹配

代码结果

easyui combobox模糊匹配_第1张图片

 

1)html代码

<select class="easyui-combobox" id="test-a" options="filter: filterCombo" style="width:200px;height:22px;">
				                          <option selected="selected"></option>
				                          <option>中通快递(ZTO)</option>
				                          <option>圆通快递(YTO)</option>
				                          <option>天天快递(TT)</option>
				                          <option>国通快递(GTO)</option>
				                          <option>申通快递(STO)</option>
				                          <option>百事汇通(BSHT)</option>
				                          <option>顺丰快递(SF)</option>
				                          <option>邮政(EMS)</option>
				                      </select>

 

2)javascript 代码

 

$('#test-a').combobox({
		filter: function(q, row){
			var opts = $(this).combobox('options');
			var enterStr = q.toUpperCase();
			return row[opts.textField].indexOf(enterStr) != -1;
		}
	});

API 文档

 

lter function

Defines how to filter the local data when 'mode' is set to 'local'.

The function takes two parameters:
q: the user typed text.
row: the list row data.
Return true to allow the row to be displayed.

Code example:

$('#cc').combobox({
	filter: function(q, row){
		var opts = $(this).combobox('options');
		return row[opts.textField].indexOf(q) == 0;
	}
});

 

 

 

 

 

你可能感兴趣的:(easyui combobox模糊匹配)