Freeze filter row while remote data is loading

0 Answers 19 Views
General Discussions
mikei
Top achievements
Rank 1
mikei asked on 12 Nov 2021, 06:34 AM | edited on 13 Nov 2021, 02:45 PM

My grid is attached to remote data, my grid has filter row.
If user set one filter, and while data still is loading if set another filter on other column, gird ignores next filter settings and do not send new request to server.
In that case second filtering drops silently.(filter row set filter value but there is no request and data is not filtered)
Is there a way to some how cancel data loading when new filter event came applinked?
Is there a way to some how disable filter row of grid while data is loading ?
I do now control event of filtering in datasoruce


var sourceListaRacuna =
{
    datatype: "json",
    method: "post",
    type: "post",
    datafields: [
        { name: 'racunId', type: 'int' },
        { name: 'ts', type: 'date' },
        { name: 'sklSifra', type: 'string' },
        { name: 'sklNaziv', type: 'string' },
        { name: 'kasa', type: 'string' },
        { name: 'blagajnik', type: 'string' },
        { name: 'hrc', type: 'string' },
        { name: 'total', type: 'number' },
        { name: 'isStorno', type: 'bool' },
        { name: 'isPrekinut', type: 'bool' },
        { name: 'isPrebijanje', type: 'bool' },
        { name: 'reqL1audit', type: 'bool' },
        { name: 'reqL2audit', type: 'bool' }
    ],
    url: "../../BO/ListaRacunaData",
    key: "racunId",
    formatData: function (data) {
        return {
            'GridFilter': JSON.stringify(data),
            'initGrid': initGrid
        };
    },
    filter: function (data) {
        if (data.length === 0 || data.findIndex(x => x.datafield === 'ts') < 0) {
            $("#samo100").html("Filter datuma je obavezan");
            $('#gridRacuna').jqxGrid('clear');
            return false;
        }
        else
            {
            var ado = data.find(x => x.datafield === 'ts').filter.getfilters();

            var poruka = "";

            if (ado.length === 1) {
                poruka += "Na datum: "+ ado[0].value.toLocaleDateString();
                   }
            else {
                poruka += "Od: " + ado[0].value.toLocaleDateString() + " do " + ado[1].value.toLocaleDateString();
            }

            $("#samo100").html(poruka);
            $("#gridRacuna").jqxGrid('updatebounddata', 'filter');
        }
    }
};

Nikolay
Telerik team
commented on 16 Nov 2021, 01:16 PM

Hi Mikei,

As far as I understand you need to disable filtering while the Grid is fetching the current filtering data. Please correct me if I am wrong.

If this is so I would recommend adding CSS class .k-state-disabled to the row filter inputs in the filter event and removing the same class in the requestEnd data source event. This way the user will not be able to set new filters while the current one is executing. For example:

 $("#grid").kendoGrid({
            dataSource: {
              type: "odata",
              transport: {
                read: "https://demos.telerik.com/kendo-ui/service/Northwind.svc/Orders"
              },
              pageSize: 20,
              serverPaging: true,
              serverFiltering: true,
              requestEnd: function() {
                $("span[data-field='OrderID']").removeClass("k-state-disabled")
              }
            },
            filter: function() {
              $("span[data-field='OrderID']").addClass("k-state-disabled")
            },

Let me know if this is what you are looking for.

Regards,

Nikolay

 

No answers yet. Maybe you can help?

Tags
General Discussions
Asked by
mikei
Top achievements
Rank 1
Share this question
or