How can I use areConditionsMet/filterRowsByConditions in skuid.utils?


is displayed in the official documentation but doesn’t have any comments yet.


sounds more useful for what I want to do (client-side filtering) but is not displayed in the official documentation.

Has anyone used this? Or can an employee pitch in an unofficial mention of the number of parameters and their types?


I had to solve this one quickly so I wrote a function that checks conditions for only boolean type condition/values.

//only handles true and false values now checkcondition = function(row,condition){ //used in the eval expression. If we used '=' instead of '==' we'd get an assignment error. operatermap = {}; operatermap['='] = '=='; operatermap['!='] = '!='; condVal = condition.value; //convert to string since condition values are of string type rowVal = row[condition.field].toString(); if(condVal != "true" && condVal!= "false"){ throw new Error("The condition provided is not a boolean type. Currently only boolean types are supported for checking."); } if(rowVal != "true" && rowVal!= "false"){ throw new Error("The row field provided is not a boolean type. Currently only boolean types are supported for checking."); } return eval(rowVal + operatermap[condition.operator] + condVal); }

Also some complimentary functions are:

//checks multiple conditions for a row and returns the row if it matches all conditions given //'row' is a single skuid row //'conditions' is an array of skuid conditions checkconditions = function(row,conditions){ checkconditionsWrapper = function(cond){ return checkcondition(row,cond); }; return conditions.every(checkconditionsWrapper); }; //checks multiple conditions on multiple rows and returns all rows that match all conditions //'rows' is an array of skuid data rows //'conditions' is an array of skuid conditions (you can put an array of a single condition if necessary) filterRowsByConditions = function(rows,conditions){ rowFilterWrapper = function(row){ return checkconditions(row,conditions); }; return rows.filter(rowFilterWrapper); };