Need to reset model condition.

  • 2
  • Question
  • Updated 3 years ago
I have added table in popup.
When I am opening that popup I need to reset the all the filter plus search box.

My Current problem
I am clicking on popup and searching anything into the search box.
After that when I am close the popup that search result appear again.
After that when i am trying with different text it is not give me any result.
So I need to reset model condition when I am clicking on popup.
So I have done below code but it is not working.Please provide some solution for that.
=========================
var params = arguments[0],
    $ = skuid.$;
var Job_Seekermodel1 = skuid.$M("Job_Seeker");
var searchCondition;
for (var i = 0; i < Job_Seekermodel1.conditions.length; i++)
{
 searchCondition = Job_Seekermodel1.conditions[i];
 Job_Seekermodel1.deactivateCondition(searchCondition);
 }


Job_Seekermodel1.updateData();
======================================
Photo of Rohit Vakhariya

Rohit Vakhariya

  • 1,054 Points 1k badge 2x thumb

Posted 3 years ago

  • 2
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Functionally, the search box acts as a condition. Is it part of skuid.model.Model.conditions? That would be super-cool. and make it easier to 'search' with javascript. But if what Rohit is trying doesn't work, then it's probably not.

Rohit -- have you tried a simple requery of the model? Does a requery reset the search?
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,490 Points 10k badge 2x thumb
We need to provide better APIs to get at the search condition on a model.  Also we need to prevent multiple search conditions from being created on the same model.  

In the mean time, try changing your code to only deactivate search conditions.  Put the following if statement around your deactivateCondition line.

if (searchCondition.name.indexOf('_searchbox') !== -1) {
   Job_Seekermodel1.deactivateCondition(searchCondition);
}