Deactivate a model's filterable conditions using Javascript

  • 3
  • Question
  • Updated 5 years ago
  • Answered
Further to this post: http://community.skuidify.com/skuid/t...

In the same function, before I set the model's condition, I want to deactivate all other filterable conditions so that I can be sure that the user is seeing the right set of data. I know how to deactivate conditions by name (as described here: http://community.skuidify.com/skuid/t...). But we can't know for sure at runtime how many filters there are, so this is too hard-codey. And I don't want to deactivate all conditions for the model, just filterable ones. Is there a simple property to check perhaps?

Thanks ... and happy new year. May it be as huge as 2013, eh?

Glenn.
Photo of Glenn Elliott

Glenn Elliott, Champion

  • 7,738 Points 5k badge 2x thumb
  • anticipating a middle-aged-dad-style NYE

Posted 5 years ago

  • 3
Photo of Glenn Elliott

Glenn Elliott, Champion

  • 7,738 Points 5k badge 2x thumb
Still wondering on this one. Any thoughts? Thx.
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
My advice would be to iterate over all Conditions in the Model, and if a Condition's "name" property is set, then assume it's Filterable, as only Filterable Conditions should have Names.

var $ = skuid.$;
var myModel = skuid.model.getModel('Opportunities');
$.each(myModel.conditions,function(i,condition){
if (condition.name) myModel.deactivateCondition(condition);
});

Photo of Glenn Elliott

Glenn Elliott, Champion

  • 7,738 Points 5k badge 2x thumb
Ah yes, that makes sense, and very simple. I'll give it a try.
Photo of Glenn Elliott

Glenn Elliott, Champion

  • 7,738 Points 5k badge 2x thumb
Yep, works like a charm. Thanks.