jquery easyui combobox模糊過濾(範例程式碼)_jquery

來源:互聯網
上載者:User

修改jquery easyui combobox模糊過濾

複製代碼 代碼如下:

filter:function(q,row){
var opts=$(this).combobox("options");

//return row[opts.textField].indexOf(q)==0;//

return row[opts.textField].indexOf(q)>-1;//將從頭位置匹配改為任意匹配
},formatter:function(row){
var opts=$(this).combobox("options");
return row[opts.textField];
},loader:function(_7c9,_7ca,_7cb){
var opts=$(this).combobox("options");
if(!opts.url){
return false;
}

修改easyui combobox擴充可以預設選擇第一行

easyui的combobox擴充預設選擇第一行,網上有瘋狂秀才的那個被轉載了無數次的代碼,但是那個只是針對easyui1.2.6的,試了一下在1.3.2下不行的,自己重新寫了一個擴充方法如下:

複製代碼 代碼如下:

$.extend($.fn.combobox.methods, {
    selectedIndex: function (jq, index) {
        if (!index) {
            index = 0;
        }
        $(jq).combobox({
            onLoadSuccess: function () {
                var opt = $(jq).combobox('options');
                var data = $(jq).combobox('getData');

                for (var i = 0; i < data.length; i++) {
                    if (i == index) {
                        $(jq).combobox('setValue', eval('data[index].' + opt.valueField));
                        break;
                    }
                }
            }
        });
    }
});

調用方法執行個體如下:
複製代碼 代碼如下:

<script type="text/javascript">
var currenturl = "om_taking.aspx";
        $(function () {
            $('#dept').combobox({
                url: currenturl + "?act=loadDept",
                valueField: 'DEPARTMENT_ID',
                textField: 'DEPARTMENT_NAME'
            }).combobox('selectedIndex', 0);
        });
</script>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.