toolbarFilter.setFilterValue Erratic Behavior

Discuss all problems you have with Servoy here. It might help to mention the Servoy version and Operating System version you are using

toolbarFilter.setFilterValue Erratic Behavior

Postby john1598360627 » Mon Mar 27, 2023 7:25 pm

Changing a filter’s value programmatically isn’t consistent.

After using setFilterValue multiple times it doesn’t seem to properly apply. I’m not sure why it’s doing this.

I created an example solution for this but I can't post it on the forums. Will be attached to a support ticket later.

METHOD
I have a class that contains the toolbar filter itself. This contains the functions to add and set filter values.

I extend this onto a grid form, which updates the set value for each added filter by clicking on buttons I made.


PROBLEM
When I click on my custom buttons to change the set value for a filter, the results will just be wrong.

  • Duplicate records will appear
  • Records with incorrect value related to the filter will appear

Though, searching some text and then changing the filter seems to fix it. But, when I tried to add even that programmatically it didn't help. Something is just not working and I do not know why!


Any help is appreciated!

CODE
class.js
Code: Select all
/**
* @param {String} Text
* @param {String} Provider
* @param {String} Type
*
* @public
*
* @return {Filter}
*
* @properties={typeid:24,uuid:"A09E378C-D905-43C7-AA9F-D375D958046B"}
*/
function add_toolbarFilter( Text, Provider, Type ) {
   
   var filter = toolbarFilter.addFilter( Text, Provider, Type )
   
   
   
//   application.output( filter )
   
   return filter
   
}

/**
* @param {Filter} Filter
* @param {Array} Value
* @param {String} Operatr
*
* @public
*
* @properties={typeid:24,uuid:"4183AD40-079A-428C-9D9C-7B696171725A"}
*/
function set_toolbarFilter( Filter, Value, Operatr ) {
   
   toolbarFilter.setFilterValue( Filter, Value, Operatr )
   
}




grid.js
Code: Select all
/**
* @properties={typeid:24,uuid:"8AC2CB6C-FFB5-426D-9780-0D189DFD3005"}
*/
function ini_filtering() {
   
   var f_archive = add_toolbarFilter( 'archival', 'archive', scopes.svyToolbarFilter.FILTER_TYPES.INTEGER )
   
   set_toolbarFilter( f_archive, [0], scopes.svyPopupFilter.OPERATOR.EQUALS )
   
   filter_Archive = f_archive
   
   var f_type = add_toolbarFilter( 'type', 'type', scopes.svyToolbarFilter.FILTER_TYPES.INTEGER )
   
   set_toolbarFilter( f_type, [], scopes.svyPopupFilter.OPERATOR.NOT_NULL )
   
   filter_Type = f_type
   
}

/**
* @public
*
* @properties={typeid:24,uuid:"090D915F-A6E2-42F1-8C5C-268FF02EBB13"}
*/
function update_filterArchive( Type ) {
   
   // reset
//   set_toolbarFilter( filter_Archive, [], scopes.svyPopupFilter.OPERATOR.EQUALS )
   
   switch( Type )
   {
      case scopes.Filter.def_Archive.current:
         set_toolbarFilter( filter_Archive, [0], scopes.svyPopupFilter.OPERATOR.EQUALS )
      break;
      
      case scopes.Filter.def_Archive.archived:
         set_toolbarFilter( filter_Archive, [1], scopes.svyPopupFilter.OPERATOR.EQUALS )
      break;
      
      case scopes.Filter.def_Archive.all:
         set_toolbarFilter( filter_Archive, [], scopes.svyPopupFilter.OPERATOR.EQUALS_OR_NULL )
      break;
      
      default:
         
      
   }
   
   reset_search()
   
   reset_search()
   
//   foundset.reloadWithFilters()
}

/**
* @public
*
*
* @properties={typeid:24,uuid:"AC7119E9-2ABD-481E-A992-87C68B1CD273"}
*/
function update_filterType( Type ) {
   
   
   // reset
//   set_toolbarFilter( filter_Type, [], scopes.svyPopupFilter.OPERATOR.NOT_NULL )
   
   switch( Type )
   {
      case scopes.Filter.def_Type.all:
         set_toolbarFilter( filter_Type, [], scopes.svyPopupFilter.OPERATOR.NOT_NULL )
      break;
      
      case scopes.Filter.def_Type.car:
         set_toolbarFilter( filter_Type, ['car'], scopes.svyPopupFilter.OPERATOR.LIKE )
      break;
      
      default:
         
   }
   
   reset_search()
   
}


john1598360627
 
Posts: 191
Joined: Tue Aug 25, 2020 3:03 pm

Re: toolbarFilter.setFilterValue Erratic Behavior

Postby kwpsd » Mon Mar 27, 2023 8:04 pm

Created Support Ticket: SVYX-603 with example solution.
Kim W. Premuda
San Diego, CA USA
User avatar
kwpsd
 
Posts: 701
Joined: Sat Jul 28, 2007 6:59 pm
Location: San Diego, CA USA

Re: toolbarFilter.setFilterValue Erratic Behavior

Postby john1598360627 » Thu Apr 06, 2023 3:33 am

Integrating this into my main project proper, it seemed to work better.

Perhaps there's another issue going on here. This could be a glitch related to low record count in a table. Or perhaps, maybe its related to me using a memory table here for the demonstration.

Because in contrast, in my main project I'm using a database table and large record count.


I realized to I setup this code wrong so here's the fix for that atleast;
Code: Select all
/**
* @public
*
* @properties={typeid:24,uuid:"090D915F-A6E2-42F1-8C5C-268FF02EBB13"}
*/
function update_filterArchive( Type ) {

   switch( Type )
   {
      case scopes.Filter.def_Archive.current:
         set_toolbarFilter( filter_Archive, [0], scopes.svyPopupFilter.OPERATOR.EQUALS )
      break;
     
      case scopes.Filter.def_Archive.archived:
         set_toolbarFilter( filter_Archive, [1], scopes.svyPopupFilter.OPERATOR.EQUALS )
      break;
     
      case scopes.Filter.def_Archive.all:
         set_toolbarFilter( filter_Archive, [0], scopes.svyPopupFilter.OPERATOR.GREATER_EQUAL )
      break;
     
      default:
         
     
   }
 
}


I applied this fix and the issue still happens within the sandbox so something strange be going on!
john1598360627
 
Posts: 191
Joined: Tue Aug 25, 2020 3:03 pm

Re: toolbarFilter.setFilterValue Erratic Behavior

Postby mboegem » Fri Apr 07, 2023 3:12 pm

Hi John,

when you use the 'EQUALS' operator, it seems that you can only filter on 1 value.
Using the 'IS_IN' operator will resolve this.

This might explain the issue you've encountered.
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1817
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: toolbarFilter.setFilterValue Erratic Behavior

Postby john1598360627 » Sat Apr 08, 2023 2:12 am

mboegem wrote:Hi John,

when you use the 'EQUALS' operator, it seems that you can only filter on 1 value.
Using the 'IS_IN' operator will resolve this.

This might explain the issue you've encountered.

Hmmm, that would be odd though. I set the filter type to number, so I should be able to use equal and greater than equals. Which in fact it does in my main project.

Though, I did notice I am setting the type for my string related filter to integer. Oops, yeah that should be Token I suppose.
john1598360627
 
Posts: 191
Joined: Tue Aug 25, 2020 3:03 pm

Re: toolbarFilter.setFilterValue Erratic Behavior

Postby john1598360627 » Wed Apr 12, 2023 12:16 am

I have encountered what the symptom appears to be. It relates to a low record count in the foundset of the data grid.

Basically, when using these filters and the result is of a lower record count it for some reason bugs out. However, if there's alot of records this behavior doesn't happen and is fine.

This is how it's manifesting in my main project, where it works fine when there's alot of records, but glitches out when the result is of a low record count.
john1598360627
 
Posts: 191
Joined: Tue Aug 25, 2020 3:03 pm


Return to Discuss possible Issues and Bugs

Who is online

Users browsing this forum: No registered users and 17 guests