Kusumoto / PrimeNG.TableFilter

Helper for use the PrimeNG table load lazy filter in backend use LINQ to Entity
MIT License
17 stars 10 forks source link

Global Filters not Working #31

Open rileybwesley opened 1 year ago

rileybwesley commented 1 year ago

I noticed the global filters are not working. Made a quick work around to handle:

        protected virtual void ProvisionGlobalSearchPayload(ref TableFilterModel tableFilterPayload, string[] props)
        {
            if (!tableFilterPayload.Filters.ContainsKey("global"))
                return;
            foreach (var prop in props)
            {
                var value = (tableFilterPayload.Filters["global"] as JObject)["value"];
                var matchMode = (tableFilterPayload.Filters["global"] as JObject)["matchMode"];
                if (tableFilterPayload.Filters.ContainsKey(prop))
                {
                    tableFilterPayload.Filters[prop] = new JArray { new JObject
                    {
                        ["value"] = value,
                        ["matchMode"] = matchMode,
                        ["operator"] = "or"
                    }};
                }
                else
                {
                    tableFilterPayload.Filters.Add(prop, new JObject
                    {
                        ["value"] = value,
                        ["matchMode"] = matchMode,
                        ["operator"] = "or"
                    });
                }
            }
            tableFilterPayload.Filters.Remove("global");
        }

Forces you to define global filters on serverside but seems to work nice :)

Might be able to use this to work it into the library...

Kusumoto commented 1 year ago

Hi rileybwesley

Thank you for your solution. Your solution make me inspire for implement global filter for this library.

rileybwesley commented 1 year ago

No problem :)