Refine A Search Function

Certified Senior Developer

Good day,

I'd like to implement a search function in an interface, but I'm struggling to make it work. Once the user types in a search term and presses the search button, the appropriate results should return.

The code : 

a!localVariables(
local!search: false,
local!searchTerm,
local!searchTitles: {
"Amadori",
"Telpark",
"Microsystem",
"Kone"
},
local!searchData: a!dataSubset(
data: rule!JT_CONS_CASE_STUDIES(),
batchSize: - 1,
startIndex: 2,
sort: a!sortInfo(field: "title", ascending: true)
),
local!searchField: index(
local!searchTerm,
wherecontains(local!searchTitles, local!searchData)
),
{
a!sectionLayout(
label: "",
contents: {
rule!JT_uiCaseStudyDashboard(numberOfColumns: 3)
},
showWhen: local!search,
isCollapsible: true
),
a!sideBySideLayout(
items: {
a!sideBySideItem(
item: a!textField(
labelPosition: "COLLAPSED",
placeholder: "Search Use Cases",
value: local!searchTerm,
saveInto: local!searchTerm,
)
),
a!sideBySideItem(
item: a!buttonArrayLayout(
buttons: {
a!buttonWidget(
icon: "search",
value: rule!APP_safeIndex(
dictionary: rule!JT_CONS_CASE_STUDIES(),
path: "dictionary.title"
),
/* The save here would use local!searchTerm to perform the search */
saveInto: { a!save(local!search, not(local!search)) },
size: "SMALL",
style: "NORMAL",
accessibilityText: "Search"
)
},
marginBelow: "NONE"
),
width: "MINIMIZE"
)
},
alignVertical: "MIDDLE",
spacing: "DENSE"
)
}
)

The user needs to search according to title of this list of dictionary :

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    Certified Senior Developer
    in reply to Stefan Helzle

    I'm struggling to get my search to work. I need it to, once I type a word in the textField, it should return a case study ( rule!JT_CONS_CASE_STUDIES ). Now, I have all the data and it captures the names and saves it into the local variable ( local!searchData ). But that's that...

    So I need help to just return the correct case study that's captured in the local variable. For example, if I search for Kone : 

    It should return this :

    Then the user has the ability to click on the card and then read more about the specific case study.

    Thank you for the recipe, but I'd like it to not be displayed in a grid. What am I doing wrong in my code provided?

  • 0
    Certified Lead Developer
    in reply to n_vdl

    I suggest to work with that recipe and understand all the details of how it works. Then adapt it to your needs.