demo/developmentArea.js
function paginatorCallback(page, pageSize, options){
            console.log(options);

            var filtersApplied = options.columnFilter;
            var offset = (page-1) * pageSize;
            var result = nutritionList;

            if(filtersApplied[0].length) {
                result = _.filter(nutritionList, function (aNutrition) {
                    var res = false;

                    _.each(filtersApplied[0], function(filteredNutrition){
                        if(res){
                            return;
                        }

                        res = aNutrition.fields.item_name.indexOf(filteredNutrition.fields.item_name) !== -1;
                    });

                    return res;
                });
            }

            if(filtersApplied[1].length) {
                result = _.filter(result, function (aNutrition) {
                    var res = false;

                    _.each(filtersApplied[1], function(filteredNutrition){
                        if(res){
                            return;
                        }

                        res = aNutrition.fields.nf_serving_size_unit && aNutrition.fields.nf_serving_size_unit.toLowerCase() == filteredNutrition.fields.nf_serving_size_unit && filteredNutrition.fields.nf_serving_size_unit.toLowerCase();
                    });

                    return res;
                });
            }

            if(filtersApplied[2].length) {
                result = _.filter(result, function (aNutrition) {
                    var res = false;

                    _.each(filtersApplied[2], function(fatObject){
                        if(res){
                            return;
                        }

                        res = fatObject.comparator(aNutrition.fields.nf_total_fat);
                    });

                    return res;
                });
            }

            return $q(function(resolve, reject){
                setTimeout(function(){
                    resolve({
                        results: result.slice(offset, offset + pageSize),
                        totalResultCount: result.length
                    });
                },1000);
            });
        }
function paginatorCallback(page, pageSize, options){
            console.log(options);

            var filtersApplied = options.columnFilter;
            var offset = (page-1) * pageSize;
            var result = nutritionList;

            if(filtersApplied[0].length) {
                result = _.filter(nutritionList, function (aNutrition) {
                    var res = false;

                    _.each(filtersApplied[0], function(filteredNutrition){
                        if(res){
                            return;
                        }

                        res = aNutrition.fields.item_name.indexOf(filteredNutrition.fields.item_name) !== -1;
                    });

                    return res;
                });
            }

            if(filtersApplied[1].length) {
                result = _.filter(result, function (aNutrition) {
                    var res = false;

                    _.each(filtersApplied[1], function(filteredNutrition){
                        if(res){
                            return;
                        }

                        res = aNutrition.fields.nf_serving_size_unit && aNutrition.fields.nf_serving_size_unit.toLowerCase() == filteredNutrition.fields.nf_serving_size_unit && filteredNutrition.fields.nf_serving_size_unit.toLowerCase();
                    });

                    return res;
                });
            }

            if(filtersApplied[2].length) {
                result = _.filter(result, function (aNutrition) {
                    var res = false;

                    _.each(filtersApplied[2], function(fatObject){
                        if(res){
                            return;
                        }

                        res = fatObject.comparator(aNutrition.fields.nf_total_fat);
                    });

                    return res;
                });
            }

            return $q(function(resolve, reject){
                setTimeout(function(){
                    resolve({
                        results: result.slice(offset, offset + pageSize),
                        totalResultCount: result.length
                    });
                },1000);
            });
        }
function paginatorCallback ( page , pageSize , options ) { console . log ( options ) ; var filtersApplied = options . columnFilter ; var offset = ( page - 1 ) * pageSize ; var result = nutritionList ; if ( filtersApplied [ 0 ] . length ) { result = _ . filter ( nutritionList , function ( aNutrition ) { var res = false ; _ . each ( filtersApplied [ 0 ] , function ( filteredNutrition ) { if ( res ) { return ; } res = aNutrition . fields . item_name . indexOf ( filteredNutrition . fields . item_name ) !== - 1 ; } ) ; return res ; } ) ; } if ( filtersApplied [ 1 ] . length ) { result = _ . filter ( result , function ( aNutrition ) { var res = false ; _ . each ( filtersApplied [ 1 ] , function ( filteredNutrition ) { if ( res ) { return ; } res = aNutrition . fields . nf_serving_size_unit && aNutrition . fields . nf_serving_size_unit . toLowerCase ( ) == filteredNutrition . fields . nf_serving_size_unit && filteredNutrition . fields . nf_serving_size_unit . toLowerCase ( ) ; } ) ; return res ; } ) ; } if ( filtersApplied [ 2 ] . length ) { result = _ . filter ( result , function ( aNutrition ) { var res = false ; _ . each ( filtersApplied [ 2 ] , function ( fatObject ) { if ( res ) { return ; } res = fatObject . comparator ( aNutrition . fields . nf_total_fat ) ; } ) ; return res ; } ) ; } return $q ( function ( resolve , reject ) { setTimeout ( function ( ) { resolve ( { results : result . slice ( offset , offset + pageSize ) , totalResultCount : result . length } ) ; } , 1000 ) ; } ) ; }
table search endpoint Don't look carefully the implementation details of this method, since it's just emulates an API call which increases the complexity of it. What happens here is just simply playing with the values passed with `filtersApplied` parameter, and trying to filter the array of nutritions.
table search endpoint Don t look carefully the implementation details of this method since it s just emulates an API call which increases the complexity of it . What happens here is just simply playing with the values passed with filtersApplied parameter and trying to filter the array of nutritions .