Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtering not working #258

Closed
zopyx opened this issue Apr 20, 2016 · 6 comments
Closed

Filtering not working #258

zopyx opened this issue Apr 20, 2016 · 6 comments
Labels

Comments

@zopyx
Copy link

zopyx commented Apr 20, 2016

I've integrated jsgrid 1.4.1 into the Plone CMS with filtering enabled. However the filtering does not work (keypress events are possibly eaten or ignored somewhere, somehow)....how can I track this done.

See http://public.zopyx.com/filtering.mp4

@tabalinas
Copy link
Owner

Are you sure you've implemented actual data filtering on client or server side?

@zopyx
Copy link
Author

zopyx commented Apr 20, 2016

This is my configuration:

            $('#table').jsGrid({
                width: "100%",
                height: "600px",
                autoload: true,
                sorting: true,
                paging: PAGING,
                filtering: true,
                controller: {
                    loadData: get_data
                },

                fields: [
                    { name: "title", title: "Name", type: "text", width: 200,  itemTemplate: title_renderer},
                    { name: "type", title: "Type", type: "text", width: 75, css: 'field-type'},
                    { name: "size", title: "Size", type: "text", width: 50, css: 'field-size', filtering: false},
                    { name: "modified", title: "Last modified", type: "text", css: 'field-modified', filtering: false },
                    { name: "st_mode_text", title: "Permissions", type: "text", sorting: false, size: 50 , filtering: false},
                    { name: "actions", type: "text", title: "Actions", sorting: false, itemTemplate: action_renderer, filtering: false}
                ]
            });

        });

The "basic scenario" demo does not show anything special that would be different from my code.
Is there anything missing in the documentation? Setting autosearch: true does not make a difference.

@zopyx
Copy link
Author

zopyx commented Apr 20, 2016

I checked that the event handler for keypress works for the enter key. The grid.search() gets called (however with 'filter' being undefined). From reading the docs: default filtering should work out of the box without custom filtering code, correct?

@tabalinas
Copy link
Owner

Nope, the data filtering logic is on the developer shoulders for the sake of flexibility and simplicity. Please see the following ticket: #32.
Maybe it should be stated clearer in the docs.

@tabalinas tabalinas changed the title Filtering now working Filtering not working Nov 11, 2016
@dewelloper
Copy link

dewelloper commented Aug 28, 2017

                        loadData: function (filter) {
                            criteria = filter;
                            var data = $.Deferred();
                            $.ajax({
                                type: "GET",
                                contentType: "application/json; charset=utf-8",
                                url: "/fapplications",
                                dataType: "json"
                                }).done(function(response){
                                    var res = [];
                                    if(criteria.Name !== "")
                                    {
                                        response.forEach(function(element) {
                                            if(element.Name.indexOf(criteria.Name) > -1){
                                                res.push(element);
                                                response = res;
                                            }
                                        }, this);
                                    }
                                    else res = response;
                                    if(criteria.Title !== "")
                                    {
                                        res= [];
                                        response.forEach(function(element) {
                                            if(element.Title.indexOf(criteria.Title) > -1)
                                                res.push(element);
                                        }, this);
                                    }
                                    else res = response;                                    

                                    data.resolve(res);
                                });
                            return data.promise();
                        },

@sharepointmike
Copy link

My Json result does not let me do "IndexOf". Any solution in my case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants