我目前在我的项目中使用 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 列中删除这个搜索工具栏?