[TIP 84] Using a Textbox Filter to add a Search Box to your Dashboard

If your users are used to doing search operations on your data, you can expose such search functionality using the Textbox filter. Simply select the metric set you want the users to be able to search on and add a Textbox filter connected to the field that users would want to search.


That will give you the basic search functionality. You can then further customize the search by controlling the search operator (i.e. switch from contains to exact match or starts with or ends with), hide the token menu, change the labels etc.


Note that if you do end up hiding the token menu, you would probably want to add the script below to the Textbox value changed action. This script is needed in order to ensure that searching by no value returns all values again.


Image title


Click on the image to see an example of this Search Box in action


Script:


var canvaseService = dundas.context.getService("CanvasService");

if (canvaseService.canvasAdapter.control.viewParameters[1].parameterValue.token != null)

{

// user has entered nothing and the 'no selection' token is being passed

// change the parameter to nothing

canvaseService.canvasAdapter.control.viewParameters[1].parameterValue.token = null;

canvaseService.canvasAdapter.control.viewParameters[1].parameterValue.value = '';

canvaseService.canvasAdapter.control.viewParameters[1].refreshAllAdapters();

}

Hey Jordan


I have 2 questions about this.


  1. Is it possible for the search to happen as you type? At present you need to press enter or click away to trigger the value changed interaction.
  2. My parameter seems to be different to yours. Your parameter is of type 'single string' but the one I have is 'collection member'. What causes this to happen? It means that I need to set an 'all' token rather than a blank string to get all the values.


Thanks

1. This is the way it will behave on a value filter search but not on the textbox filter. This tip is just a way to use the textbox filter as search but the main purpose behind this filter is indeed to filter and not search. If you want the search to search as you type values then go with the value filter and use the native search for that control.

Image title


2. Maybe you used it on a hierarchy that was setup in the data cube while in this example this is done without any data cube setup directly on the source value. The result however is the same, a script is required to set back the value to all when nothing is entered.