Adding Conditions to an Extant Model. Is it possible?

Dan ArnisonDan Arnison Member
edited February 2017 in Questions
Hi Guys,

I've got a use case where I want to filter a model based on varied conditions that a user might select. The problem is that I don't know what these conditions will be ahead of time.

So my question:

Is it possible to add conditions to a model at dynamically at run-time? I don't mean activating quiescent conditions with setCondition, but rather adding a totally new condition and re-querying an existing model.

I've tried variants of this type of thing, but just can't get the new condition into the query.
var tasksModel = skuid.$M('Tasks');
tasksModel.conditions.push({ type: 'fieldvalue', field: 'Id', operator: '=', value: 'Apple', inactive: false, name: 'Apple', encloseValueInQuotes: true }) tasksModel.initialize().register().updateData(); tasksModel.soql;
Any ideas would be greatly appreciated.

Dan Arnison


  • Matt SonesMatt Sones Member ✭✭
    edited February 2017

    I would have expected what you're doing there to work.
    Perhaps include
    tasksModel.isInitialized = false;
     before you initialize and query again?

    Perhaps try creating a 'blank' condition, and modifying the values of that condition via javascript?

    Alternatively, you can just dynamically create the whole model.
  • Dan ArnisonDan Arnison Member
    edited December 2016
    Thanks Matt. I gave that a try; no joy.

    Also, I cannot readily create a new model dynamically because existing components are bound at design time.

Sign In or Register to comment.