jQuery UI Widgets › Forums › Grid › Restricting user to enter certain characters in jqxGrid column filter
Tagged: character, createfilterwidget, Enter, filter, filter row, grid, jqxgrid, key, restrict, showfilterrow
This topic contains 1 reply, has 2 voices, and was last updated by Dimitar 9 years, 8 months ago.
Viewing 2 posts - 1 through 2 (of 2 total)
-
Author
-
January 22, 2015 at 10:23 am Restricting user to enter certain characters in jqxGrid column filter #65834
Hey there,
As per the requirement, I would like to restrict the user from entering certain characters like ‘”‘,’/’ etc. in the column filter.Could you propose a solution for this?
January 22, 2015 at 10:47 am Restricting user to enter certain characters in jqxGrid column filter #65836Hello shivam,
If you are using filter row (
showfilterrow: true
), you can use the createfilterwidget callback to achieve your requirement. Here is how:<!DOCTYPE html> <html lang="en"> <head> <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" /> <script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxlistbox.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxdropdownlist.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxmenu.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.filter.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.sort.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.selection.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxpanel.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxcalendar.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxdatetimeinput.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxcheckbox.js"></script> <script type="text/javascript" src="../../jqwidgets/globalization/globalize.js"></script> <script type="text/javascript" src="../../scripts/demos.js"></script> <script type="text/javascript" src="generatedata.js"></script> <script type="text/javascript"> $(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 dataAdapter = new $.jqx.dataAdapter(source); $("#jqxgrid").jqxGrid( { width: 850, source: dataAdapter, showfilterrow: true, filterable: true, selectionmode: 'multiplecellsextended', columns: [ { text: 'Name', columntype: 'textbox', filtertype: 'input', datafield: 'name', width: 215, createfilterwidget: function (column, columnElement, widget) { var restricted = [',', '/']; // a list of restricted characters widget.on('keydown', function (event) { if (restricted.indexOf(event.key) !== -1) { return false; } }); } }, { text: 'Product', filtertype: 'checkedlist', datafield: 'productname', width: 220 }, { text: 'Available', datafield: 'available', columntype: 'checkbox', filtertype: 'bool', width: 67 }, { text: 'Ship Date', datafield: 'date', filtertype: 'range', width: 210, cellsalign: 'right', cellsformat: 'd' }, { text: 'Qty.', datafield: 'quantity', filtertype: 'number', cellsalign: 'right' } ] }); $('#clearfilteringbutton').jqxButton({ height: 25 }); $('#clearfilteringbutton').click(function () { $("#jqxgrid").jqxGrid('clearfilters'); }); }); </script> </head> <body class='default'> <div id="jqxgrid"> </div> <input style="margin-top: 10px;" value="Remove Filter" id="clearfilteringbutton" type="button" /> </body> </html>
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.