jqGrid filterToolbar():无法读取未定义的属性“length”

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jqGrid filterToolbar():无法读取未定义的属性“length”相关的知识,希望对你有一定的参考价值。

所以我正在尝试将我正在处理的网站上的jquery从1.4升级到3.3,并且我的jqgrid存在问题。我有一个html表,我正在使用tableToGrid函数转换为jqgrid,一切都很好,直到我尝试添加filterToolbar。我也在使用jqGrid 5.3.1。这是代码的片段

    <table id='warrantytable' class='tableinquiry' >
   <thead>
      <tr>
         <th>Item<br/>Number</th>
         <th>Order<br/>Number</th>
         <th>WH Status</th>
         <th>Kit SKU</th>
         <th>Purchase<br/>Source</th>
         <th>Store</th>
         <th>Effective<br/>Date</th>
         <th>Production<br/>Code</th>
         <th>Factory<br/>Code</th>
         <th>Smart<br/>Serial Number</th>
         <th>Actual<br/>Serial Number</th>
         <th>Serial<br/>Date</th>
         <th>Serial<br/>Factory Code</th>
         <th>Registration<br/>Date</th>
         <th>User ID</th>
         <th>Expiration<br/>Date</th>
         <th>Warranty<br/>Item</th>
         <th>Warranty<br/>Type</th>
         <th>Warranty<br/>Duration</th>
         <th>Edit</th>
         <th>Info</th>
      </tr>
   </thead>
   <tbody>
      <tr class='highlight'>
         <td align='center'>S3101</td>
         <td align='center'>10000601-00</td>
         <td align='center'>Open Order</td>
         <td align='center'></td>
         <td align='center'>F156</td>
         <td align='center'></td>
         <td align='center'>08/29/18</td>
         <td align='center'></td>
         <td align='center'></td>
         <td align='center'></td>
         <td align='center'></td>
         <td align='center'></td>
         <td align='center'></td>
         <td align='center'>08/29/18</td>
         <td align='center'>sheldoN@fdm4.com</td>
         <td align='center'>03/05/20</td>
         <td align='center'></td>
         <td align='center'>Make-it-right</td>
         <td>554</td>
         <td><a onclick="javascript:_lastwarrantyrow = $('#warrantytable').jqGrid ('getGridParam', 'selrow'); warrantyUpdate('','','no');"> <img class='imgstyle' title='Edit warranty' width='16px' height='16px' /></a></td>
         <td></td>
      </tr>      
   </tbody>
</table>
<script>
tableToGrid('#warrantytable',{autowidth: true, forcefit: true  });
$('#warrantytable').each(function(){$('#warrantytable').jqGrid('setColProp','Edit',{search: false});
$('#warrantytable').jqGrid('setColProp','Edit',{sortable: false});
$('#warrantytable').jqGrid('setColProp','Info',{search: false});
$('#warrantytable').jqGrid('setColProp','Info',{sortable: false});
$('#warrantytable').jqGrid('setColProp','ItemNumber',{searchoptions: {clearSearch: false}});
$('#warrantytable').jqGrid('setColProp','OrderNumber',{searchoptions: {clearSearch: false}});
$('#warrantytable').jqGrid('setColProp','WH_Status',{searchoptions: {clearSearch: false}});
$('#warrantytable').jqGrid('setColProp','Kit_SKU',{searchoptions: {clearSearch: false}});
$('#warrantytable').jqGrid('setColProp','PurchaseSource',{searchoptions: {clearSearch: false}});
$('#warrantytable').jqGrid('setColProp','Store',{searchoptions: {clearSearch: false}});
$('#warrantytable').jqGrid('setColProp','ProductionCode',{searchoptions: {clearSearch: false}});
$('#warrantytable').jqGrid('setColProp','FactoryCode',{searchoptions: {attr: {maxlength: 2}, clearSearch: false}});
$('#warrantytable').jqGrid('setColProp','SmartSerialNumber',{searchoptions: {attr: {maxlength: 12}, clearSearch: false}});
$('#warrantytable').jqGrid('setColProp','ActualSerialNumber',{searchoptions: {attr: {maxlength: 16}, clearSearch: false}});
$('#warrantytable').jqGrid('setColProp','SerialDate',{searchoptions: {attr: {maxlength: 10}, clearSearch: false}});
$('#warrantytable').jqGrid('setColProp','SerialFactoryCode',{searchoptions: {attr: {maxlength: 2}, clearSearch: false}});
$('#warrantytable').jqGrid('setColProp','User_ID',{searchoptions: {clearSearch: false}});
$('#warrantytable').jqGrid('setColProp','ExpirationDate',{searchoptions: {clearSearch: false}});
$('#warrantytable').jqGrid('setColProp','WarrantyItem',{searchoptions: {clearSearch: false}});
$('#warrantytable').jqGrid('setColProp','WarrantyType',{searchoptions: {clearSearch: false}});
$('#warrantytable').jqGrid('setColProp','WarrantyDuration',{searchoptions: {clearSearch: false}});

$('#warrantytable').jqGrid('setColProp','EffectiveDate',{search: true, searchoptions: { sopt: ['eq'],dataInit: function (elem) { $(elem).datepicker({ dateFormat: 'mm/dd/y',changeYear:true,onSelect:function(){if(this.id.substr(0,3) === 'gs_'){setTimeout(function(){$('#warrantytable')[0].triggerToolbar();},50);}else{$(this).trigger('change');}} }) } }});
$('#warrantytable').jqGrid('setColProp','RegistrationDate',{search: true, searchoptions: { sopt: ['eq'],dataInit: function (elem) { $(elem).datepicker({dateFormat: 'mm/dd/y',changeYear:true,onSelect:function(){if(this.id.substr(0,3) === 'gs_'){setTimeout(function(){$('#warrantytable')[0].triggerToolbar();},50);}else{$(this).trigger('change');}} }) } }});;});

<!-- this is the error line -->
$("#warrantytable").filterToolbar({searchOperators : true});

if(_lastwarrantyrow != 0){$('#warrantytable').setSelection(_lastwarrantyrow,false);}

$(window).bind('resize', function() {$('#warrantytable').setGridWidth($(window).width() * 0.98);}).trigger('resize');
$(window).bind('resize', function() {winHeight = $(window).height();wHeight = winHeight - (winHeight * 0.5);if(wHeight < 125){wHeight = 125;}$('#warrantytable').jqGrid('setGridHeight',wHeight); }).trigger('resize');
</script>

我的网格仍然显示,排序/大小/等工作,它只是不会显示过滤器工具栏jqgrid display

答案

您的代码非常完美。您需要检查其中的其他内容。这是jsfiddle of your code

Bellow部分代码

var _lastwarrantyrow;
tableToGrid('#warrantytable',{autowidth: true, forcefit: true  });
$('#warrantytable').each(function(){$('#warrantytable').jqGrid('setColProp','Edit',{search: false});
$('#warrantytable').jqGrid('setColProp','Edit',{sortable: false});
$('#warrantytable').jqGrid('setColProp','Info',{search: false});
$('#warrantytable').jqGrid('setColProp','Info',{sortable: false});
$('#warrantytable').jqGrid('setColProp','ItemNumber',{searchoptions: {clearSearch: false}});

以上是关于jqGrid filterToolbar():无法读取未定义的属性“length”的主要内容,如果未能解决你的问题,请参考以下文章

jQgrid filterToolbar 因 searchOnEnter 而失败

JQGrid filterToolbar搜索输入列合并

jqGrid filterToolbar 仅适用于某些列

无法绑定 jqGrid 列

jqgrid 分组无法正常工作

为啥 JQGrid 无法显示数据?