question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typeahead/Select component with remote data source

See original GitHub issue

I am trying to use these components with remote data source but I do not understand how to configure. I think it is better to create a parameter like that:

suspend fun getOptions(search?: String): List<String>

It is more customizable and I can use that with the base component (~remote~).

I have seen the ajax options for the base component, I mean AjaxOptions class, but to separate the UI components from the business logic, I prefer to use a custom service class.

On the other hand, I have not been seeing a function parameter to display each option of the components. I mean I want to include images and more information like a description or a date. Currently, I can only see a list of items.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
rjaroscommented, Sep 15, 2020
1reaction
rjaroscommented, Sep 7, 2020

In fact it’s easy to add source parameter to the Typeahead/TypeaheadInput component, because it’s already there in the underlying JS component. I’ve just kept it hidden, because I’ve modeled these components to have similar API to the Select/SelectInput components. I will expose source parameter in the next version.

But note:

  1. Source function will not be suspendin, because I’m trying to avoid coroutines dependency whenever possible. So if you like to use remote service you will have to run some coroutines scope:
typeahead(
  label = "Customers",
  source = { search, callback ->
     GlobalScope.launch {
         CustomerService.searchByEmail(search) { customers ->
            val processedData = customers.map { it.email }.toTypedArray() 
             callback(processedData)
         }
     }
  }
)
  1. Unfortunately it’s possible only for Typeahead component and not for Select. The Bootstrap Select component does not support dynamic data sources other than those supported by the AJAX extension.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Typeahead.js with remote data source - Stack Overflow
The typeahead.js script is activated correctly, but it interprets the data source as only one comma separated item instead of separate items.
Read more >
typeahead.js – examples - Twitter Open Source
Remote. Remote data is only used when the data provided by local and prefetch is insufficient. In order to prevent an obscene number...
Read more >
Autocomplete with Remote Data Source - MDBootstrap
I'm trying to make a "Author Search" component. This is an autocomplete component that binds to an Author. Authors have the structure of...
Read more >
Typeahead control for Blazor applications - GitHub
The SelectedTemplate is used to display the selected item and the ResultTemplate is used to display each result in the search list. Remote...
Read more >
Create a Type Ahead Block Element Unit | Salesforce Trailhead
If you've ever started typing in an input field and selected a record from the list of results that appears, you've experienced type-ahead...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found