jQWidgets Forums

jQuery UI Widgets Forums Grid Initial date filter fails with remote data

This topic contains 6 replies, has 2 voices, and was last updated by  nikitaso 9 years, 8 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author

  • nikitaso
    Participant

    In your sample http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/index.htm#demos/jqxgrid/initialfilter.htm, if you try to use “initial filter” on date column – it works good. But if you using remote data (url request) – it fails.

    I have source code for 3.6 version, it fails on in “getcolumn” function (grid.columns.records is null).


    ivailo
    Participant

    Hi nikitaso,

    Please try to update to the latest version 3.8.2

    Best Regards,
    Ivailo Ivanov

    jQWidgets Team
    http://www.jqwidgets.com


    nikitaso
    Participant

    sample using local data: http://status.axeom.us/datefilter-local.html

    remote data: http://status.axeom.us/datefilter-remote.html
    Getting error: Cannot read property ‘cellsformat’ of null

    Samples use full jqx ver 3.8.2


    ivailo
    Participant

    Hi nikitaso,

    The problem probably is in your server settings.

    Testing your code the console says:
    Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://status.axeom.us/api/demodata/positions?filterscount=0&groupscount=0&pagenum=0&pagesize=10&recordstartindex=0&recordendindex=18&_=1440662703471. (Reason: CORS header 'Access-Control-Allow-Origin' missing).
    So this article may help you.

    Best Regards,
    Ivailo Ivanov

    jQWidgets Team
    http://www.jqwidgets.com


    nikitaso
    Participant

    I made change on server to allow cross domain access.

    But – it’s not even getting to the point where it makes request to server, it fails before. Btw, it does not fail for other data types like string or int. Only datetime. Please help.

    http://status.axeom.us/datefilter-date.html NOT WORKING

    Here is the sample with no initial filter http://status.axeom.us/datefilter-remote-nofilter.html, makes request and works fine

    Sample with string filter (WORKS!) http://status.axeom.us/datefilter-string.html

    Do you have a sample with initial filter, remote data and datetime field?


    ivailo
    Participant

    Hi nikitaso,

    Please try to add your filter on ready.
    Here is your code after a bit of transformation.

    
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <title id='Description'>
            The demo shows how to apply a filter during the Grid's initialization.
        </title>
        <link rel="stylesheet" href="http://www.jqwidgets.com/jquery-widgets-demo/jqwidgets/styles/jqx.base.css" type="text/css" />
        <script type="text/javascript" src="http://www.jqwidgets.com/jquery-widgets-demo/scripts/jquery-1.11.1.min.js"></script>
        <script type="text/javascript" src="http://status.axeom.us/scripts/jq-3-8-2/jqx-all.js"></script>
    
        <script type="text/javascript">
            $(document).ready(function () {
                var data = [{ "Id": 124, "Cusip": "00162FAB", "Maturity": "2019-02-28T00:00:00" }, { "Id": 262, "Cusip": "006806DE0", "Maturity": "2019-09-01T00:00:00" }, { "Id": 261, "Cusip": "008560BN3", "Maturity": "2019-08-15T00:00:00" }, { "Id": 299, "Cusip": "008560BN3", "Maturity": "2019-08-15T00:00:00" }, { "Id": 322, "Cusip": "008560BN3", "Maturity": "2019-08-15T00:00:00" }, { "Id": 323, "Cusip": "022555LH7", "Maturity": "2015-08-01T00:00:00" }, { "Id": 113, "Cusip": "03832TAB", "Maturity": "2019-06-28T00:00:00" }, { "Id": 263, "Cusip": "040504FM9", "Maturity": "2038-03-01T00:00:00" }, { "Id": 257, "Cusip": "05518UAA", "Maturity": "2043-03-15T00:00:00" }, { "Id": 302, "Cusip": "05518UAA", "Maturity": "2043-03-15T00:00:00" }];
    
                //
                  var source =
                {
                    url: 'http://status.axeom.us/api/demodata/positions',
    
                   //  localdata:data,
                    datatype: "json",
                    datafields:
                    [
                        { name: 'Id', type: 'int' },
                        { name: 'Cusip', type: 'string' },
                        { name: 'Maturity', type: 'date' }
                    ]
                };
    
                var adapter = new $.jqx.dataAdapter(source);
    
    			var dateColumnFilter = function () {
    				var filtergroup = new $.jqx.filter();
    				var filter_or_operator = 1;
    				var filtervalue = '1/1/2022';
    				var filtercondition = 'GREATER_THAN';
    				var filter = filtergroup.createfilter('datefilter', filtervalue, filtercondition);
    				filtergroup.addfilter(filter_or_operator, filter);
    
    				$("#jqxgrid").jqxGrid('addfilter', 'Maturity', filtergroup);
    				$("#jqxgrid").jqxGrid('applyfilters');
    			}
    
                $("#jqxgrid").jqxGrid(
                {
                    width: 850,
                    source: adapter,
                    filterable: true,
                    sortable: true,
                    showfilterrow: true,
    				ready: function () {
    					dateColumnFilter();
    				},
                    columns: [
                      
                      { text: 'Cusip', datafield: 'Cusip', width: 160 },
                      { text: 'Maturity', datafield: 'Maturity', filtertype: 'date', width: 160, cellsformat: 'M/dd/yyyy' }
                    ]
                });
            });
        </script>
    </head>
    <body class='default'>
        <div id="jqxgrid">
        </div>
    </body>
    </html>
    
    

    Best Regards,
    Ivailo Ivanov

    jQWidgets Team
    http://www.jqwidgets.com

    Initial date filter fails with remote data #75415

    nikitaso
    Participant

    Looks like a workaround 🙂
    Will you address issue in next release?

    Thank you!

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

You must be logged in to reply to this topic.