Jqgrid filterToolbar不起作用 [英] Jqgrid filterToolbar is not working

查看:131
本文介绍了Jqgrid filterToolbar不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码



< script type =text / javascript>

$(document).ready(function( ){

$(#list)。jqGrid({



url:'@ Url.Action(GetList,列表)',

数据类型:'json',

mtype:'GET',

colNames:['No.',' name','Action'],

colModel:[

{name:'Id',index:'id',width:15,sortable:false,search: false,editable:false,formatter:numberFormat,align:center,resizable:false},

{name:'Name',index:'Vendor Name',width:50,search:true ,sortable:false,editable:false,resizable:false,searchoptions:{sopt:['cn','eq','ne']}},

{name:'Action',index :'Action',width:30,sortable:false,search:false,editable:false, formatter:actionFormat,align:center,resizable:false},

],

pager:jQuery('#pager'),

rowNum:10,

rowList:[10,20,50],

shrinkToFit:true,

宽度:908,
身高:'自动',

viewrecords:true,

ignoreCase:true,

loadonce:true,

刷新:true,



jsonReader:{

root:rows,

页面:page,

总计:总计,

记录:记录,

repeatitems:false,

},



})。navGrid('#pager',{edit:false,add:false,del:false,search:false,ref resh:false,searchtext:Search});

$(。ui-jqgrid-titlebar)。hide();





$(#list)。jqGrid('filterToolbar',{stringResult:true,searchOnEnter:false,defaultSearch:'cn'});



$(#list)。setGridParam({data:results.rows,localReader:reader})。trigger('reloadGrid');



});





函数numberFormat(cellvalue,options,rowObject){

return( (parseInt($('#list')。getGridParam('page')) - 1)* parseInt($('#list')。getGridParam('rowNum')))+ parseInt(options.rowId);

}



函数actionFormat(cellvalue,options,rowObject){

return'查看';

}

< / script>

解决方案

(文件).ready(function(){


(#list)。jqGrid({



url:'@ Url.Action(GetList,List)',

数据类型:'json',

mtype:'GET',

colNames:[''','name','Action'],

colModel:[

{name:'Id',index:' id',width:15,sortable:false,search:false,editable:false,formatter:numberFormat,align:center,resizable:false},

{name:'Name',index :'Vendor Name',宽度:50,搜索:true,sortable:false,editable:false,resizable:false,searchoptions:{sopt:['cn','eq','ne']}},
{name:'Action',index:'Action',width:30,sortable:false,search:false,editable:false,formatter:actionFormat,align:center,resizable:false},

],

寻呼机:jQuery('#pager'),

rowNum:10,

rowList:[10,20,50],

shrinkToFit:true,

宽度:908,

身高:'自动',

viewrecords:true,

ignoreCase:true,

loadonce:true,

refresh:true,



jsonReader:{

root:rows,

page:page,

总计:total,

记录:记录,

重复项:false,

},



} ).navGrid('#pager',{edit:false,add:false,del:false,search:false,refresh:false,searchtext:Search});


(。UI-JQ grid-titlebar)。hide();





my code

<script type="text/javascript">
$(document).ready(function () {
$("#list").jqGrid({

url: '@Url.Action("GetList", "List")',
datatype: 'json',
mtype: 'GET',
colNames: ['No.', 'name', 'Action'],
colModel: [
{ name: 'Id', index: 'id', width: 15, sortable: false, search: false, editable: false, formatter: numberFormat, align: "center", resizable: false },
{ name: 'Name', index: 'Vendor Name', width: 50, search: true, sortable: false, editable: false, resizable: false, searchoptions: { sopt: ['cn' ,'eq', 'ne']}},
{ name: 'Action', index: 'Action', width: 30, sortable: false, search: false, editable: false, formatter: actionFormat, align: "center", resizable: false },
],
pager: jQuery('#pager'),
rowNum: 10,
rowList: [10, 20, 50],
shrinkToFit: true,
width: 908,
height: 'auto',
viewrecords: true,
ignoreCase: true,
loadonce: true,
refresh: true,

jsonReader: {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false,
},

}).navGrid('#pager', { edit: false, add: false, del: false, search: false, refresh: false, searchtext: "Search" });
$(".ui-jqgrid-titlebar").hide();


$("#list").jqGrid('filterToolbar', { stringResult: true, searchOnEnter: false, defaultSearch: 'cn' });

$("#list").setGridParam({data: results.rows, localReader: reader}).trigger('reloadGrid');

});


function numberFormat(cellvalue, options, rowObject) {
return ((parseInt($('#list').getGridParam('page')) - 1) * parseInt($('#list').getGridParam('rowNum'))) + parseInt(options.rowId);
}

function actionFormat(cellvalue, options, rowObject) {
return 'View';
}
</script>

解决方案

(document).ready(function () {


("#list").jqGrid({

url: '@Url.Action("GetList", "List")',
datatype: 'json',
mtype: 'GET',
colNames: ['No.', 'name', 'Action'],
colModel: [
{ name: 'Id', index: 'id', width: 15, sortable: false, search: false, editable: false, formatter: numberFormat, align: "center", resizable: false },
{ name: 'Name', index: 'Vendor Name', width: 50, search: true, sortable: false, editable: false, resizable: false, searchoptions: { sopt: ['cn' ,'eq', 'ne']}},
{ name: 'Action', index: 'Action', width: 30, sortable: false, search: false, editable: false, formatter: actionFormat, align: "center", resizable: false },
],
pager: jQuery('#pager'),
rowNum: 10,
rowList: [10, 20, 50],
shrinkToFit: true,
width: 908,
height: 'auto',
viewrecords: true,
ignoreCase: true,
loadonce: true,
refresh: true,

jsonReader: {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false,
},

}).navGrid('#pager', { edit: false, add: false, del: false, search: false, refresh: false, searchtext: "Search" });


(".ui-jqgrid-titlebar").hide();



这篇关于Jqgrid filterToolbar不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆