我目前正在我的项目中使用jqGrid,因为我是这个数据网格的新手,我正在接受jQWidgets的帮助
在这里,我使用了排序,添加行,删除行和过滤行。代码如下:
// initialize jqxGrid
$("#jqxgrid").jqxGrid(
{
width: 900,
source: dataadapter,
theme: theme,
editable: true,
height: 300,
pageable: true,
sortable: true,
showfilterrow: true,
filterable: true,
rendergridrows: function(obj)
{
return obj.data;
},
columns: [
{ text: 'EmployeeID', editable: false, datafield: 'EmployeeID', width: 100 },
{ text: 'First Name', datafield: 'FirstName', width: 100 },
{ text: 'Last Name', datafield: 'LastName', width: 100 },
{ text: 'Title', datafield: 'Title', width: 180 },
{ text: 'Address', datafield: 'Address', width: 180 },
{ text: 'City', datafield: 'City', width: 100 },
{ text: 'Country', datafield: 'Country', width: 140 }
]
});
$("#jqxgrid").on("sort", function (event) {
// $("#events").jqxPanel('clearcontent');
var sortinformation = event.args.sortinformation;
var sortdirection = sortinformation.sortdirection.ascending ? "ascending" : "descending";
if (!sortinformation.sortdirection.ascending && !sortinformation.sortdirection.descending) {
sortdirection = "null";
}
var eventData = "Triggered 'sort' event <div>Column:" + sortinformation.sortcolumn + ", Direction: " + sortdirection + "</div>";
// $('#events').jqxPanel('prepend', '<div style="margin-top: 5px;">' + eventData + '</div>');
});
$('#clearsortingbutton').jqxButton({ height: 25, theme: theme });
$('#sortbackground').jqxCheckBox({checked: true, height: 25, theme: theme });
// clear the sorting.
$('#clearsortingbutton').click(function () {
$("#jqxgrid").jqxGrid('removesort');
});
// show/hide sort background
$('#sortbackground').on('change', function (event) {
$("#jqxgrid").jqxGrid({ showsortcolumnbackground: event.args.checked });
});
$("#addrowbutton").jqxButton({ theme: theme });
$("#deleterowbutton").jqxButton({ theme: theme });
// create new row.
$("#addrowbutton").click(function (){//alert("here");
var datarow = generaterow(); //alert(datarow['EmployeeID']);
var commit = $("#jqxgrid").jqxGrid('addrow', null, datarow);
});
// delete row.
$("#deleterowbutton").click(function () {
var selectedrowindex = $("#jqxgrid").jqxGrid('getselectedrowindex');
var rowscount = $("#jqxgrid").jqxGrid('getdatainformation').rowscount;
if (selectedrowindex >= 0 && selectedrowindex < rowscount) {//alert('here');
var id = $("#jqxgrid").jqxGrid('getrowid', selectedrowindex);
var commit = $("#jqxgrid").jqxGrid('deleterow', id);
}
});
从这段代码中,我得到了所有列中的过滤行。但我想从EmployeeId列中删除过滤器,那么我该如何从EmployeeId列中删除此搜索工具栏呢?
答案 0 :(得分:2)
您必须设置为列的正确设置是“filterable:false”
答案 1 :(得分:0)
将search: false
添加到您要禁用过滤的每列的列定义中。
columns: [
{ text: 'EmployeeID', editable: false, datafield: 'EmployeeID', width: 100, search: false },
{ text: 'First Name', datafield: 'FirstName', width: 100 },
{ text: 'Last Name', datafield: 'LastName', width: 100 },
{ text: 'Title', datafield: 'Title', width: 180 },
{ text: 'Address', datafield: 'Address', width: 180 },
{ text: 'City', datafield: 'City', width: 100 },
{ text: 'Country', datafield: 'Country', width: 140 }
]