A
A
Arsen4ik14882021-05-26 12:55:22
AJAX
Arsen4ik1488, 2021-05-26 12:55:22

Why doesn't sorting and filtering work in jsgrid?

why doesn't sorting the received data on the client side work?

$("#jsGrid").jsGrid({
               height: "90%",
               width: "100%",
                filtering: true,            
                sorting: true,
                paging: true,
                autoload: true,
                editing: false


Here I am getting data from elasticsearch and converting it to a string array

controller: {

               loadData: function(filter) {
                     var urls = ['http://localhost:9200/company/test/_search/?size=1000'];
                    var result = $.Deferred();

                    var results = urls.map(function(url) {
                        var d = $.Deferred();
                        $.ajax({
                            url:urls,
                            type:"post",
                            dataType: "json",
                            
                        }).done(function(data){
                            d.resolve(Object.entries(data.hits.hits).reduce((ini,[k,v])=>(ini[k]=v,ini),[]));
                        });
                        return d.promise();
                    });

                    Promise.all(results).then(function(values) {
                        result.resolve([].concat.apply([], values));
                    });

                    return result.promise();
                }
            },


here i am writing data to jsgrid grid

fields: [
                { name: "name",type: "text", itemTemplate: function(value,item)
                {
                    return item._source.name;          
                } , width: 50 },
                ]


According to the idea, when I click on the square where the column name is written, sorting should occur, an arrow appears in the corner, but sorting is not performed.

How can I fix this?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question