jQWidgets Forums

jQuery UI Widgets Forums Grid Grid custom filtering with remote json not working

This topic contains 1 reply, has 2 voices, and was last updated by  Peter Stoev 11 years, 10 months ago.

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

  • martonx
    Member

    Hi Support,

    I have this datasource and grid:

    var source = {
    datatype: ‘json’,
    datafields: [
    {“name”:”id”,”type”:”number”},
    {“name”:”gyszam”,”type”:”string”},
    {“name”:”nev”,”type”:”string”},
    {“name”:”leltarid”,”type”:”string”},
    {“name”:”bvig”,”type”:”string”}
    ],
    url: ‘/Home/GetEszkoz’,
    sortcolumn: ‘gyszam’,
    sortdirection: ‘asc’,
    pagesize: 10,
    filter: function () {
    $(‘#jqxgrid’).jqxGrid(‘updatebounddata’, ‘filter’);
    },
    sort: function () {
    $(‘#jqxgrid’).jqxGrid(‘updatebounddata’, ‘sort’);
    },
    root: ‘Rows’,
    beforeprocessing: function (data) {
    source.totalrecords = data.TotalRows;
    }
    };

    var dataadapter = new $.jqx.dataAdapter(source);

    $(‘#jqxgrid’).jqxGrid({
    width: ‘100%’,
    theme: ‘darkblue’,
    autoheight: true,
    selectionmode: ‘singlerow’,
    source: dataadapter,
    showtoolbar: true,
    filterable: true,
    showfilterrow: true,
    sortable: true,
    pageable: true,
    pagesizeoptions: [’10’, ’25’, ’50’],
    virtualmode: true,
    rendergridrows: function () {
    return dataadapter.records;
    },
    columns: [
    {“text”:”id”,”datafield”:”id”,”width”:0,”hidden”:true},
    {“text”:”Gyári szám”,”datafield”:”gyszam”,”width”:150,”hidden”:false},
    {“text”:”Tipus”,”datafield”:”nev”,”width”:150,”hidden”:false},
    {“text”:”Leltár kód”,”datafield”:”leltarid”,”width”:90,”hidden”:false},
    {“text”:”BVIG”,”datafield”:”bvig”,”width”:120,”hidden”:false}
    ]
    });

    This is working remotely filter, page, sort on server side. It is Ok. After the grid was initaialized, loaded with datas, if I would like to use a filter programmatically like this (for example with a button click):

    $(“#jqxgrid”).jqxGrid(‘clearfilters’);
    var filtergroup = new $.jqx.filter();
    var filteroperator = 1; // 1 – and, 0 – or
    var filtervalue = event.args.row.gyszam;
    var filter = filtergroup.createfilter(‘stringfilter’, filtervalue, ‘contains’);
    filtergroup.addfilter(filteroperator, filter);
    $(‘#jqxgrid’).jqxGrid(‘addfilter’, “gyszam”, filtergroup, true); //this line code is broken

    I got this error message to console:

    jqxGrid: The data is still loading. When the data binding is completed, the Grid raises the ‘bindingcomplete’ event. Call this function in the ‘bindingcomplete’ event handler.

    Please advice,

    Lajos


    Peter Stoev
    Keymaster

    Hi Lajos,

    The message says it clear: It is not possible to add/remove filters, do sort or change a Page while the Binding operation is not completed. When it is, the Grid will raise a “bindingcomplete” event and you will be able to add your custom filters.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

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

You must be logged in to reply to this topic.