Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

How to create an interactive filter for a string field?

MR Carvalho
Tera Contributor

Hi all,

I'm using a Tokyo version and I'm trying to create  an interactive filter for a string field, I found on community a code but it didnt work, following below:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<script>
var my_dashboardMessageHandler = new DashboardMessageHandler("my_unique_id");

function searchForStrings (str) {
var filter_message = {};
filter_message.id = "my_unique_id";
filter_message.table = "task";

filter_message.filter = "short_descriptionLIKE" + str;
SNC.canvas.interactiveFilters.setDefaultValue({
id: filter_message.id,
filters: [filter_message]
},false);
my_dashboardMessageHandler.publishFilterMessage(filter_message.table,filter_message.filter);
}


</script>

Short description <br/>

<input id="myCustomsearchForStrings" type="text" value="" onChange="searchForStrings(this.value);" />

</j:jelly>

 

 

Is there something I can do?

1 ACCEPTED SOLUTION

The code is the same as what you had,  I have it for the task table, and short description, if you need to search on any other fields you need to update the "ShortDescription" value 

View solution in original post

8 REPLIES 8

Tsura Andreeva
Mega Sage

Yes you need to create Dynamic Content with the code and then you can use it in a dashboardDynamicContent.JPGexmple.JPG

Hey Tsura,  

 

Could you please, send me your code?

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
&lt;script&gt;
var my_dashboardMessageHandler = new DashboardMessageHandler("my_unique_id");

function publishFilter () {
var filter_message = {};
filter_message.id = "my_unique_id";
filter_message.table = "task";
var value = gel('cfShortDescription').value;
filter_message.filter = "short_descriptionLIKE" + value;
SNC.canvas.interactiveFilters.setDefaultValue({
id: filter_message.id,
filters: [filter_message]
}, false);
my_dashboardMessageHandler.publishFilter(filter_message.table, filter_message.filter);
}

function clearFilter() {
var filter_message = {};
filter_message.id = "my_unique_id";
filter_message.table = "task";
filter_message.filter = "";
gel('cfShortDescription').value = '';
SNC.canvas.interactiveFilters.setDefaultValue({
id: filter_message.id,
filters: [filter_message]
}, false);
my_dashboardMessageHandler.removeFilter();
}
&lt;/script&gt;

Short Description:
<input id="cfShortDescription" type="input" value="" /><br/>
<input id="removeCustomFilter" type="button" value="Clear" onclick="clearFilter();" />
<input id="addCustomFilter" type="button" value="Search" onclick="publishFilter();" />

</j:jelly>

The code is the same as what you had,  I have it for the task table, and short description, if you need to search on any other fields you need to update the "ShortDescription" value