jQuery UI Widgets › Forums › Grid › Excel and String filter in one Grid
This topic contains 2 replies, has 3 voices, and was last updated by millhorn 2 years, 6 months ago.
-
Author
-
Hi ,
I have a constrain ,for one column I need String filter like AND , OR , contains and another column I need excel filter . Kindly guide me how to proceed.
If I use filtermode: ‘excel’ all the column appended by checkbox filter here I’m not able to override one some column to String filter.
$(document).ready(function() {
var data = generatedata(500);
var source =
{
localdata: data,
datafields:
[
{name: ‘name’, type: ‘string’},
{name: ‘productname’, type: ‘string’},
{name: ‘available’, type: ‘bool’},
{name: ‘date’, type: ‘date’},
{name: ‘quantity’, type: ‘number’}
],
datatype: “array”
};var addfilter = function() {
// create a filter group for the FirstName column.
var fnameFilterGroup = new $.jqx.filter();
fnameFilterGroup.operator = ‘or’;
// operator between the filters in the filter group. 1 is for OR. 0 is for AND.
var filter_or_operator = 1;
// create a string filter with ‘contains’ condition.
var filtervalue = ‘la’;
var filtercondition = ‘contains’;
var fnameFilter1 = fnameFilterGroup.createfilter(‘stringfilter’, filtervalue, filtercondition);
// create second filter.
filtervalue = ‘la’;
filtercondition = ‘starts_with’;
var fnameFilter2 = fnameFilterGroup.createfilter(‘stringfilter’, filtervalue, filtercondition);
// add the filters to the filter group.
fnameFilterGroup.addfilter(filter_or_operator, fnameFilter1);
fnameFilterGroup.addfilter(filter_or_operator, fnameFilter2);
// add the filter group to the ‘firstname’ column in the Grid.
$(“#jqxgrid”).jqxGrid(‘addfilter’, ‘name’, fnameFilterGroup);//
// apply the filters.
$(“#jqxgrid”).jqxGrid(‘applyfilters’);
}var dataAdapter = new $.jqx.dataAdapter(source);
$(“#jqxgrid”).jqxGrid(
{
width: 685,
source: dataAdapter,
ready: function() {
addfilter();
},
autoshowfiltericon: true,
filtermode: ‘excel’,
pagesize: 20,
pagesizeoptions: [’20’, ’50’, ‘100’],
//showfilterrow: true,
filterable: true,
sortable: true,
selectionmode: ‘multiplecellsextended’,
columns: [
{text: ‘Name’, filtertype: ‘textbox’, datafield: ‘name’, width: 115},
{
text: ‘Product’, filtertype: ‘checkedlist’, datafield: ‘productname’, width: 220
},
{text: ‘Available’, datafield: ‘available’, columntype: ‘checkbox’, filtertype: ‘bool’, width: 67},
{text: ‘Ship Date’, datafield: ‘date’, filtertype: ‘date’, width: 210, cellsalign: ‘right’, cellsformat: ‘d’},
{text: ‘Qty.’, datafield: ‘quantity’, filtertype: ‘excel’, cellsformat: ‘c2’ ,cellsalign: ‘right’}
]
});});
Thanks in advance
Regards,
StanleyHi Stanley,
Sorry, but it is not possible to combine the Grid filter menu types. You can use one type or another.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comI know this post is a bit old, but I think jQWidgets has been updated quite a bit in the last 8 years. If anyone is looking for an example on mixing
filtertype
within individual columns, I put up an example here: https://codepen.io/r3hab/pen/poLOXao -
AuthorPosts
You must be logged in to reply to this topic.