JQGrid不支持多个筛选条件的自动完成

时间:2012-03-06 15:43:58

标签: jquery jqgrid jquery-autocomplete

我有一个带有多个标题的JQGrid和两个启用了自动完成功能的列。 当我转到JQGrid过滤器并选择其中一个要启用自动完成功能的过滤列时,它可以正常工作,并且按预期调用自动完成功能。但是,当我添加第二列以过滤同时包含自动完成功能的结果时,自动完成功能不适用于新过滤器,它还会禁用先前过滤器上的自动完成功能。

这就是AutoComplete的代码:

Common.setAutoComplete = function (id, url, select, change, extraParams)
    {
      id.autocomplete(
      {
        source: function (request, response)
        {
            alert("start of autocomplete");
            $.ajax(
            {
                url: url,
                data: { query: request.term, extraParameters: extraParams },
                dataType: 'json',
                type: 'POST',
                success: function (data)
                {
                    if (data)
                        response(data);
                }
            });
        },
        delay: 10,
        minChars: 1,
        matchSubset: 1,
        matchContains: 1,
        cacheLength: 400,
        select: select,
        change: change,
        autoFill: true
    });
    };

JQGrid的输出如下所示:

<script type="text/javascript">
var invalidRows = [];
var allRowsValid = true;
var validRows = [];
var IssuerListTablerowId;
var IssuerListTablehasDefaultFilter = true;
var currentTableRowId;
var rowsToSave = [];
var IssuerListTablerowsToSave = [];
var currentTableId = 'IssuerListTable';
     $(document).ready(function(){

     $('#IssuerListTable').jqGrid({

     url:        '/Issuers/GetAll/',
     mtype:      'POST',
     datatype:   'json',
     colNames: ['Issuer', 'ICN', 'Contact', 'Broker'],

     colModel: [
     {"sortable":true, "search":true, "editable":false, "hidden":false, name: 'Name', editrules:{}, addrules:{}, searchoptions: {sopt: ['cn','nc'], searchhidden:true,hidden:false,dataInit:function(a){Common.setAutoComplete($(a),'/Issuers/GetIssuerByShortNameAndLongNameForAutoComplete',null);}} }, 
     {"sortable":true, "search":true, "editable":false, "hidden":false, name: 'ICN', editrules:{}, addrules:{}, searchoptions: {sopt: ['cn','nc'], searchhidden:true,hidden:false} , width: 30}, 
     {"sortable":true, "search":true, "editable":false, "hidden":false, name: 'Contact', editrules:{}, addrules:{}, searchoptions: {sopt: ['cn','nc'], searchhidden:true,hidden:false} , width: 50},     
     {"sortable":true, "search":true, "editable":false, "hidden":false, name: 'Broker', editrules:{}, addrules:{}, searchoptions: {sopt: ['cn','nc'], searchhidden:true,hidden:false,dataInit:function(a){Common.setAutoComplete($(a),'/Brokers/GetBrokersByNameForAutoComplete',false);}} , width: 90}],

onSelectRow: function(id){

                        window.location = '/Issuer/' + id ;      

                    },

     multiselect: false,    
     pager: $('#IssuerListPager'),
     editurl:        '',    
     rowNum: 20,    
     pgbuttons: false,    
     pginput: false,    
     rowList: [],    
     scrollRows: true,    
     scroll: 1,    
     recordtext: "{2} Records",    
     rowNumbers: false,    
     sortname:   '',    
     sortorder: "asc",    
     hiddengrid: false,    
     caption:    '',    
     subGrid: false,    
     toppager: false,
     height: 400,   
     shrinkToFit: true,
     autowidth: true,
     viewrecords: true,
     altClass:   'altRow',
     altRows: true,

  loadComplete: function (data) { $('#IssuerListTable').trigger('jqGrid_loadComplete_ongrid', data); return; },

     gridComplete: function() { $(document).trigger('jqGrid_gridComplete');$('#IssuerListTable').trigger('jqGrid_gridComplete_ongrid');Pfc.Common.DisplaySearchDataInPager('IssuerListTable','IssuerListPager',IssuerListTablehasDefaultFilter); return; },

     beforeRequest: function() { var event = $.Event('jqGrid_beforeRequest'); $('#IssuerListTable').trigger(event); return !event.isDefaultPrevented(); },

     beforeSelectRow: function(rowid, e) {  var event = jQuery.Event('jqGrid_beforeSelectRow'); $('#IssuerListTable').trigger(event, [rowid, e]); return !event.isDefaultPrevented(); },

     onSelectAll: function(rowids, status) { $('#IssuerListTable').trigger('jqGrid_onSelectAll', [status, rowids]); },

     });

     $('#IssuerListTable').jqGrid('navGrid', '#IssuerListPager', {edit:false, edittext:'Edit', add:false, addtext:'Add', del:false, deltext:'Delete', search:true, searchtext:'Search', view:false}, {/**/ }, {/*Add*/beforeShowForm:function(){} }, {reloadAfterSubmit:true, mtype:'POST', url:''}, { search:true, groupOps: [ { op: "AND", text: "any"} ],  searchtext: 'Search',  caption: "Search Issuers",  Reset: "Clear",  closeAfterSearch: true,  closeOnEscape: true,  multipleSearch: true }, {/*view*/});$('#IssuerListTable').jqGrid('navButtonAdd', '#IssuerListPager', {position:'first', caption:'Add', buttonicon:'ui-icon-plus', onClickButton: function(){$(location).attr('href', '/Issuer/Add')}});

     });

</script>

谢谢。

0 个答案:

没有答案