jQWidgets Forums

Forum Replies Created

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts

  • anjo
    Participant

    Upd:

    That is wrong.
    “I can use a workaround and set ‘contains’ condition to 3d position but it doesn’t look flexible”

    I can not use this workaround because when I place ‘contains’ to 3d position – ‘equal’ becomes default on first load, after manual addfilter/removefilter ‘contains’ becomes default condition as expected. So default filter condition is not ‘contains’ either on first load or after changes


    anjo
    Participant

    Sorry for disturbing again. All your advice are considered and working. but one more bug appeared (The code is below).
    STR
    1) set a string filter value with default ‘contains’ condition
    2) delete the filter value using keyboard (backspace or delete buttons) (set the filter empty)
    AR: the filter condition is changed to ‘equal’ (3d position)
    ER: the filter condition remains unchanged (contains)

    The above provided example from you shows the same behaviour.
    I can use a workaround and set ‘contains’ condition to 3d position but it doesn’t look flexible

    <!DOCTYPE html
    PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
    <html lang=”en”>

    <head>
    <title>Grid filtering</title>
    <link rel=”stylesheet” href=”./jqwidgets/styles/jqx.base.css” type=”text/css” />
    <link rel=”stylesheet” href=”./jqwidgets/styles/jqx.darkblue.css” type=”text/css” />
    <script type=”text/javascript” src=”https://code.jquery.com/jquery-1.12.4.min.js”
    integrity=”sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=” crossorigin=”anonymous”></script>
    <script type=”text/javascript” src=”https://code.jquery.com/ui/1.12.1/jquery-ui.min.js”
    integrity=”sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=” crossorigin=”anonymous”></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/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/jqxmenu.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/jqxgrid.js”></script>
    <script type=”text/javascript” src=”./jqwidgets/jqxgrid.selection.js”></script>
    <script type=”text/javascript” src=”./jqwidgets/jqxgrid.columnsresize.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.pager.js”></script>
    <script type=”text/javascript” src=”./jqwidgets/jqxgrid.grouping.js”></script>
    <script type=”text/javascript” src=”./jqwidgets/jqxcheckbox.js”></script>
    <script type=”text/javascript” src=”./jqwidgets/jqxgrid.storage.js”></script>
    </head>

    <body>
    <script type=”text/javascript”>

    function configureFilters(type, defaultconditions) {
    if (type == ‘stringfilter’)
    return [‘CONTAINS’, ‘DOES_NOT_CONTAIN’,’EQUAL’, ‘NOT_EQUAL’];
    }

    function bindData() {
    var data = {
    localdata:
    [
    { Id: 1, Number: ‘Number 1’, Description: ‘Description 1’ },
    { Id: 2, Number: ‘Number 2’, Description: ‘Description 2’ },
    { Id: 3, Number: ‘Number 3’, Description: ‘Description 3’ },
    ],
    datatype: ‘array’,
    datafields: [
    { name: ‘Id’, type: ‘number’ },
    { name: ‘Number’, type: ‘string’ },
    { name: ‘Description’, type: ‘string’ }
    ]
    }

    var dataAdapter = new $.jqx.dataAdapter(data);
    $(“#grid”).jqxGrid({ source: dataAdapter });

    }

    $(document).ready(function () {
    var state;
    var columns =
    [
    {
    datafield: ‘Id’,
    text: ‘Id’,
    width: 50,
    filtertype: ‘number’,
    cellsformat: ‘n’,
    },
    {
    datafield: ‘Number’,
    columntype: ‘textbox’,
    filtertype: ‘input’,
    width: 200,
    },
    {
    datafield: ‘Description’,
    columntype: ‘textbox’,
    filtertype: ‘input’,
    width: 200,
    }
    ];

    $(“#grid”).on(‘bindingcomplete’, () => {
    console.log(‘data bound’);
    var localizationobj = {};
    filterstringcomparisonoperators = [‘cOnTaInS’, ‘dOeS nOt CoNtAiN’,’eQuAl’, ‘nOt_EqUaL’];
    localizationobj.filterstringcomparisonoperators = filterstringcomparisonoperators;
    $(“#grid”).jqxGrid(‘localizestrings’, localizationobj);
    });

    $(“#grid”).jqxGrid({
    altrows: true,
    columns: columns,
    filterable: true,
    sortable: true,
    showfilterrow: true,
    updatefilterconditions: configureFilters,
    });

    console.log(‘before data binding …’);
    bindData();
    console.log(‘after data binding…’);
    });
    </script>
    <div id=”grid” />
    </body>

    </html>


    anjo
    Participant

    Hi
    You mean CONTAINS is always the default filter condition and there is no way to change it?


    anjo
    Participant

    Hi

    You provided a good, working example. But I can’t catch the magic, where you set ‘contains’ condition as default. What must I do set ‘does not contain’ as default?

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