Jsgrid: Static data and filtering

Created on 2 May 2017  路  3Comments  路  Source: tabalinas/jsgrid

I downloaded the sample and I can use the grid just fine with static data and sort and such. Filtering controls shows up, but no filtering is actually applied.

help wanted

Most helpful comment

Try to define the rules of filters in a variable.
For example:
var db = { loadData: function(filter) { return $.grep(data, function (group) { return (filter.courseId === undefined || group.courseId === filter.courseId) && (!filter.endDate || group.endDate.indexOf(filter.endDate) > -1); }); } }
Then add the variable as the value of the controller attribute when initializing jsGrid.
controller: db

$("#jsGrid").jsGrid({ height: "600px", width: "100%", filtering: true, editing: true, inserting: true, sorting: true, paging: true, autoload: true, pageSize: 15, pageButtonCount: 5, data: data, controller: db }

All 3 comments

Try to define the rules of filters in a variable.
For example:
var db = { loadData: function(filter) { return $.grep(data, function (group) { return (filter.courseId === undefined || group.courseId === filter.courseId) && (!filter.endDate || group.endDate.indexOf(filter.endDate) > -1); }); } }
Then add the variable as the value of the controller attribute when initializing jsGrid.
controller: db

$("#jsGrid").jsGrid({ height: "600px", width: "100%", filtering: true, editing: true, inserting: true, sorting: true, paging: true, autoload: true, pageSize: 15, pageButtonCount: 5, data: data, controller: db }

That did it! Thanks!

Se voc锚 veio em busca de uma solu莽茫o na qual apenas 1 linha 茅 selecionada e que tamb茅m desseleciona a mesma linha, aqui est谩 a solu莽茫o:

If you came looking for a solution in which only 1 line is selected and which also deselects the same line, here is the solution:
`selectedVal = null;

rowClick: function (args) {

         selectedVal = args.item;

         let $row = this.rowByItem(args.item);

         if ($row.hasClass("highlight") === false) {
             //Deseleciona todas as linhas
             for (let i = 0; i < this.data.length; i++) {
                 this.rowByIndex(i).removeClass("highlight");
             }
             $row.toggleClass("highlight");

         } else {
             selectedVal = null;
             $row.toggleClass("highlight");

         }
         console.log(selectedVal);
     }`
Was this page helpful?
0 / 5 - 0 ratings

Related issues

GlennSeymon picture GlennSeymon  路  5Comments

aidankilleen picture aidankilleen  路  5Comments

danielson317 picture danielson317  路  3Comments

danielson317 picture danielson317  路  6Comments

jufei picture jufei  路  3Comments