onDataChange of these buttons, I want to apply a filter to the related grid.
I want this filter to be persistent. Such that it also applies to when you search something up.
MY SETUP
I'm using the 'toolbarFilter' from svyPopupFilter. This is connected to the grid & foundset.
I have a search bar setup that runs the toolbar's search.
- Code: Select all
function search( text ) {
// combine the toolbar filter with a free searchbox
toolbarFilter.setSearchText( text );
toolbarFilter.search();
}
I know all too well about the onSearchCommand.... but how do I created or attach a custom filter to the toolbar? Or do I just load the foundset directly like the onSearchCommand is doing?
For example, I have this sort query.
- Code: Select all
/**
* @public
*
* @param {QBSelect<db:/arm_data/orders>} Query
*
* @return {QBSelect<db:/arm_data/orders>}
*
* @properties={typeid:24,uuid:"4984E184-F7B4-4D41-B04D-29F36E122F30"}
*/
function filter_OrderRank( Query ) {
Query.sort.add(
Query.case
.when( Query.columns.order_status.eq( "APPROVED") ).then( 1 )
.when( Query.columns.order_status.eq( "PENDING") ).then( 2 )
.when( Query.columns.order_status.eq( "WEB") ).then( 3 )
.when( Query.columns.order_status.eq( "TRANSREQ") ).then( 4 )
.when( Query.columns.order_status.eq( "OPEN") ).then( 5 )
.when( Query.columns.order_status.eq( "POSTED") ).then( 6 )
.when( Query.columns.order_status.eq( "RECEIVED") ).then( 7 )
.else( 8 )
)
return Query
}
And also this basic switch for filtering the value of a column.
- Code: Select all
/**
* @public
*
* @param {String} Status
*
* @param {QBSelect<db:/arm_data/orders>} Query
*
*
* @return {QBSelect<db:/arm_data/orders>}
*
* @properties={typeid:24,uuid:"5A71D59D-C4F5-45D5-8386-F9A96697EA16"}
*/
function filter_ArchivalStatus( Status, Query ) {
switch( Status )
{
case OrdersFilterOptions.archive_current:
Query.where.add( Query.columns.order_flag_archive.eq( 0 ) )
break;
case OrdersFilterOptions.archive_archive:
Query.where.add( Query.columns.order_flag_archive.eq( 1 ) )
break;
default:
}
return Query
}
HOW TO?
Is it okay if I just pass the resulting query over to the onSearchCommand?
- Code: Select all
/**
* @param query
* @param fs
*
* @protected
* @properties={typeid:24,uuid:"BF2BE7B8-143E-45F1-B2BD-243098307C02"}
*/
function onSearchCommand( query, fs) {
fs.loadRecords( query )
}
Or is there another way of setting up a filter within the toolbar itself?