jQuery UI Widgets Forums Grid Filtering empty string

This topic contains 5 replies, has 2 voices, and was last updated by  Peter Stoev 12 years, 6 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • Filtering empty string #5337

    chelli
    Member

    Hello,

    i created the grid with “filterable: true” but when i try to filter a column that contains also empty string it shows in the text box the filter condition for numeric filter(  ‘EQUAL’, ‘NOT_EQUAL’, ‘LESS_THAN’, … ). Is it possible to specify that the column contains string data so i can use the filters ‘CONTAINS’, ‘STARTS_WITH’, … ?

    Thank you in advance

    Chelli

    Filtering empty string #5372

    Peter Stoev
    Keymaster

    Hi Chelli,

    You can specify the type of your columns in the datafields array of the source object.

    For example:

    var source =
    {
    datafields: [
    {name: 'firstname', type: 'string'},
    {name: 'lastname', type: 'string'},
    {name: 'date', type: 'date'},
    {name: 'quantity', type: 'float'},
    {name: 'price', type: 'float'},
    {name: 'productname', type: 'string'}
    ],
    localdata: data,
    datatype: "array"
    };

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Filtering empty string #5373

    chelli
    Member

    Hi Peter,
    I’ve already tried this solution but it does not work. You can see my code here below:


    var source =
    {
    datatype: "json",
    datafields: [
    { name: 'description', type: 'string'},
    { name: 'timeIn', type: 'string'},
    { name: 'type', type: 'string'}
    ],
    url: uri,
    root: 'data',
    sortcolumn: 'description',
    sortdirection: 'asc',
    };

    The json object contains the following data:

    [{"type": "", "timeIn": "2012-18-06 11:46:01", "description": "test"},
    {"type": "", "timeIn": "2012-24-05 10:12:23", "description": "test2"},
    {"type": "TTT", "timeIn": "2012-24-05 10:12:23", "description": "test3"}]

    Thank you

    Chelli

    Filtering empty string #5382

    Peter Stoev
    Keymaster

    Hi Chelli,

    Do you use the latest version of jQWidgets? I tried to reproduce the issue with the following code without avail.

    Here’s my test code:

    <!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.7.2.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/jqxcheckbox.js"></script>
    <script type="text/javascript">
    $(document).ready(function () {
    var theme = '';
    data = [{ "type": "", "timeIn": "2012-18-06 11:46:01", "description": "test" },
    { "type": "", "timeIn": "2012-24-05 10:12:23", "description": "test2" },
    { "type": "TTT", "timeIn": "2012-24-05 10:12:23", "description": "test3"}]
    var source =
    {
    datatype: "json",
    datafields: [
    { name: 'description', type: 'string'},
    { name: 'timeIn', type: 'string'},
    { name: 'type', type: 'string'}
    ],
    localdata: data,
    sortcolumn: 'description',
    sortdirection: 'asc'
    };
    $("#jqxgrid").jqxGrid(
    {
    width: 670,
    source: source,
    filterable: true,
    sortable: true,
    columns: [
    { text: 'description', datafield: 'description', width: 100 },
    { text: 'timeIn', datafield: 'timeIn', width: 100 },
    { text: 'type', datafield: 'type', width: 100 }
    ]
    });
    });
    </script>
    </head>
    <body class='default'>
    <div id="jqxgrid">
    </div>
    </body>
    </html>

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Filtering empty string #5432

    chelli
    Member

    Hi Peter,
    I am using jQWidgets 2.2.0. Later I will try with jQWidgets 2.2.1.

    Thank you very much for your help.

    Chelli

    Filtering empty string #5434

    Peter Stoev
    Keymaster

    Hi Chelli,

    It actually does not matter whether the version is 2.2.0 or 2.2.1 as the 2.2.1 improvements were regarding the jqxChart. Could you try the code I provided in the previous post? If it does not work on your side, could you send me a sample which demonstrates the erroneous behavior to support@jqwidgets.com?

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.