Jqgrid filterToolbar不起作用 [英] Jqgrid filterToolbar is not working
问题描述
我的代码
< 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屋!