jQWidgets Forums
jQuery UI Widgets › Forums › Grid › filter starts_with works with one column but not the other
Tagged: grid filters
This topic contains 1 reply, has 2 voices, and was last updated by Peter Stoev 12 years, 4 months ago.
-
Author
-
Hello,
I am creating a grid with
filterable: true,
showfilterrow: true,I have three columns
When i start typing in the name field it filters fine.
If I type a 1 in the id datafield, the entire list selects, if i type in 12 i would expect the list to clear(because there are no ids that start with 12), but it does nothing.
score behaves the same. Only Name works as expected.Any help would be appreciated
id, name and score
columns: [
{ text: ‘Id’, datafield: ‘id’, filtertype: ‘textbox’, filtercondition: ‘starts_with’, width: 100 },
{ text: ‘Name’, datafield: ‘name’, filtertype: ‘textbox’, filtercondition: ‘starts_with’, width: 200 },
{ text: ‘Score’, datafield: ‘score’, filtertype: ‘textbox’, filtercondition: ‘starts_with’, width: 100 },the data looks like:
{
“completedlist”:[{“crec”:{“id”:”1000000001″,”name”:”Has,Stine”,”score”:”174.0″}}
,{“crec”:{“id”:”1000000036″,”name”:”Schout, Lyn”,”score”:”162.0″}}
,{“crec”:{“id”:”1000000020″,”name”:”Chenny, John”,”score”:””}}
,{“crec”:{“id”:”1000004088″,”name”:”Simpson, Homer”,”score”:””}}
,{“crec”:{“id”:”1000005088″,”name”:”Pinkman, Jessie”,”score”:””}}
,{“crec”:{“id”:”1000006088″,”name”:”Ho, Monty”,”score”:””}}]
}Hi,
The starts_with filter is valid only for String Columns, not for Numeric Columns(ID and Score). For numeric data you can use “less_than”, “greater_than”, etc. For more information about the filter types, see: jquery-grid-filtering.htm.
Example:
<!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.9.1.min.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxcore.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/jqxmenu.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.selection.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.filter.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxlistbox.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.sort.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxdropdownlist.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.columnsresize.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script> <script type="text/javascript" src="../../scripts/gettheme.js"></script> <script type="text/javascript"> $(document).ready(function () { var theme = getDemoTheme(); var data = [{ "id": "1000000001", "name": "Has,Stine", "score": "174.0"} , { "id": "1000000036", "name": "Schout, Lyn", "score": "162.0"} , { "id": "1000000020", "name": "Chenny, John", "score": ""} , { "id": "1000004088", "name": "Simpson, Homer", "score": ""} , { "id": "1000005088", "name": "Pinkman, Jessie", "score": ""} , { "id": "1000006088", "name": "Ho, Monty", "score": ""}]; // prepare the data var source = { datatype: "json", datafields: [ { name: 'id', type: 'number'}, { name: 'name', type: 'string' }, { name: 'score', type: 'number' } ], localdata: data }; var dataAdapter = new $.jqx.dataAdapter(source); $("#jqxgrid").jqxGrid( { width: 670, source: dataAdapter, theme: theme, columnsresize: true, filterable: true, showfilterrow: true, columns: [ { text: 'Id', datafield: 'id', filtertype: 'textbox', filtercondition: 'less_than', width: 100 }, { text: 'Name', datafield: 'name', filtertype: 'textbox', filtercondition: 'starts_with', width: 200 }, { text: 'Score', datafield: 'score', filtertype: 'textbox', filtercondition: 'greater_than', width: 100 } ] }); }); </script></head><body class='default'> <div id='jqxWidget' style="font-size: 13px; font-family: Verdana; float: left;"> <div id="jqxgrid"></div> </div></body></html>
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.