I am trying to add the suggetion in a inbuilt filter. how can i access that internal components i.e textfeild to see suggestions please give me idea about that query?
You can define a filter configuration with a property filter using the SuggestionField component:
<filter id="filter" dataLoader="usersDl">
<properties include=".*"/>
<configurations>
<configuration id="by_username" name="By username">
<propertyFilter property="username" operation="CONTAINS">
<suggestionField/>
</propertyFilter>
</configuration>
</configurations>
</filter>
You also need initialize the suggestion field in the controller when the user selects your filter configuration:
@Autowired
private UserRepository userRepository;
@Subscribe("filter")
public void onFilterConfigurationChange(Filter.ConfigurationChangeEvent event) {
Filter.Configuration configuration = event.getNewConfiguration();
if (configuration.getId().equals("by_username")) {
LogicalFilterComponent rootLogicalFilterComponent = configuration.getRootLogicalFilterComponent();
PropertyFilter propertyFilter = (PropertyFilter) rootLogicalFilterComponent.getOwnFilterComponents().get(0);
SuggestionField suggestionField = (SuggestionField) propertyFilter.getValueComponent();
suggestionField.setSearchExecutor((searchString, searchParams) ->
userRepository.getByUsernameLike(searchString).stream()
.map(UserDetails::getUsername)
.collect(Collectors.toList()));
}
}
1 Like
I am looking for dynamic filter condition suggestion
Since i can add any condition property to search values.
If i add username , first name and last name
Sometimes condition can be on active status
Putting username condition specifically seems to be more hardcoded condition.
Can you help on that if i can refer any document or mini project to achieve this.