I was struggling with some strange baheavior in filtering which I have now kind of solved but wondered if this is a bug in the grid or in my code.
When setting the default operator on a column to 'contains' the first time conducted a filter the command that was being sent to the datascource using the ODataV4Adaptor was actually 'eq'. If I then dropped down the filter bar operator menu I could see that it was correctly set to 'contains' and from then when I conducted a filter it would correctly send 'contains'.
By trial and error i found that If i removed the filter bar operator menu from my grid, so changing ..
to...
the filter then always uses the 'contains' operator.
However, now I have lost the operator selector on the filter bar which I need.
Can you please advise if this is a bug in the grid or in my code? Below is the grid code.
<script type="text/javascript">
ej.base.setCulture('en');
ej.base.setCurrencyCode('GBP');
$(document).ready(function () {
$(function () {
sfGridManagePersistence('NEWWORKFLOWFORECAST_sfGrid', true); var data = new ej.data.DataManager({
url: '/[DATASOURCE URL REMOVED]',
crossdomain: false,
adaptor: new ej.data.ODataV4Adaptor()
});
ej.grids.Grid.Inject(ej.grids.Filter, ej.grids.ExcelExport, ej.grids.PdfExport, ej.grids.Toolbar);
var NEWWORKFLOWFORECAST_sfGrid = new ej.grids.Grid({
dataSource: data,
autoFitColumns: true,
allowSorting: true,
allowReordering: true,
allowResizing: true,
allowFiltering: true,
filterSettings: { showFilterBarOperator: true},
allowPaging: true,
pageSettings: { pageSize: 10, pageSizes: true, pageCount: 10 },
allowSelection: true,
rowSelected: sfRowSelected,
rowDeselected: sfRowSelected,
showColumnChooser: true,
allowExcelExport: true,
allowPdfExport: true,
toolbar: ['ColumnChooser', 'ExcelExport', 'PdfExport'],
contextMenuItems: [{ text: 'Open Case', target: '.e-content', id: 'open' }, { text: 'Copy with headers', target: '.e-content', id: 'copywithheader' }, 'PdfExport', 'ExcelExport'],
contextMenuClick: function (args) {
if (args.item.id === 'copywithheader') {
NEWWORKFLOWFORECAST_sfGrid.copy(true);
}
if (args.item.id === 'open') {
sfOpenCase(args.rowInfo.rowData["caseid"]);
$("body").css("cursor", "progress");
}
},
columns: [
{ type: 'checkbox', width: 50 },
{ field: 'caseworkflowid', isPrimaryKey: true, width: '50', visible: true, type: 'number', headerText: 'ID' },
{ field: 'caseexternaltitle', width: '500', visible: true, type: 'string', filter: { operator: "contains" }, headerText: 'External Title' },
{ field: 'barristername', width: '400', visible: true, type: 'string', filter: { operator: "contains" }, headerText: 'Name' },
{ field: 'companyname', width: '200', visible: true, type: 'string', filter: { operator: "contains" }, headerText: 'Company Name' },
{ field: 'workflowtemplatename', width: '250', visible: true, type: 'string', filter: { operator: "contains" }, headerText: 'Workflow Template Name' }]
});
NEWWORKFLOWFORECAST_sfGrid.toolbarClick = function (args) {
if (args['item'].id === 'NEWWORKFLOWFORECAST_sfGrid_excelexport') {
NEWWORKFLOWFORECAST_sfGrid.excelExport();
}
if (args['item'].id === 'NEWWORKFLOWFORECAST_sfGrid_pdfexport') {
NEWWORKFLOWFORECAST_sfGrid.pdfExport();
}
}
NEWWORKFLOWFORECAST_sfGrid.appendTo('#NEWWORKFLOWFORECAST_sfGrid');
});
})
</script>