Notifications

19 views

Description


The keyword search of OOB Data Table widget (id:widget-data-table) appends the new 'Keyword' query to the existing filter. 

This behavior is different than the one in platform. When performing a 'for text'(Keyword) search in a list view, the previous keyword query gets overridden. 

Example scenario;

- Data table widget in Portal

  1. Enter 'test1' into Keyword search 
    • Filter becomes 'All > Keywords = test1'
  2. Enter 'test2' into Keyword search
    • Filter becomes 'All > Keywords = test1 > Keywords = test2'

- List view in Platform

  1. Enter 'test1' into Keyword search 
    • Filter becomes 'All > Keywords = test1'
  2. Enter 'test2' into Keyword search
    • Filter becomes 'All > Keywords = test2'

Reason


This behavior in portal is an expected behavior. The keyword search functionality takes place in 'Server Script' of this widget. It can be seen from the code that, first the existing filter gets set as the query, then the keyword search gets appended to this query.

if (data.filter) {
if (data.filterACLs)
gr = $sp.addQueryString(gr, data.filter);
else
gr.addEncodedQuery(data.filter);
}

if (data.keywords){
gr.addQuery('123TEXTQUERY321', data.keywords);
data.keywords = null;
}

Solution


Clone 'Data Table' widget and modify the 'data.filter' if check from;

if (data.filter) {
if (data.filterACLs)
gr = $sp.addQueryString(gr, data.filter);
else
gr.addEncodedQuery(data.filter);
}


to;

if (data.filter) {
 var filterArray = data.filter.split('^');
var newFilter = '';
for (var ind = 0; ind < filterArray.length; ind++) {
if (filterArray[ind].indexOf('123TEXTQUERY321') == -1){
newFilter += filterArray[ind] + '^';
}
}
newFilter = newFilter.slice(0, newFilter.length - 1);
if (data.filterACLs)
gr = $sp.addQueryString(gr, newFilter);
else
gr.addEncodedQuery(newFilter);
}

 

The workaround removes only the previous 'Keyword' query and replaces it with the new one. It doesn't manipulate other filter parameters.

Applicable Versions


All versions

 

Article Information

Last Updated:2018-11-12 06:50:55
Published:2018-11-12