Nativescript-ui-feedback: [RadAutoCompleteTextView] Allow passing customized Token Model

Created on 22 Feb 2017  路  14Comments  路  Source: ProgressNS/nativescript-ui-feedback

Currently, the token model allows only to set text and image and does not allows customization of the model (e.g.,.scenario where the user would want to provide two text arguments, a number argument for id and an image).

The feature: allow user customization of this model, thus providing the ability to extend and customize the tokens.

Feature request related to t.1091816

autocomplete backlog feature

Most helpful comment

Please support this feature, It is important to support id field for tokens. For example, I'm using RadAutoCompleteTextView as a search box and I i'm struggling to find the best method to get selected token index

All 14 comments

Please support this feature, It is important to support id field for tokens. For example, I'm using RadAutoCompleteTextView as a search box and I i'm struggling to find the best method to get selected token index

Consider a scenario where I have Country & City selection. I select a country from 1st RadAutoCompleteTextView and on the selection of an item I pass the country 'ID' to fetch the cities and bind that list to another RadAutoCompleteTextView for city selection.

This is an important and frequently required feature in various scenarios! Please provide a workaround or a solution as early as possible :thumbsup:

I would also like to know if this feature is going to be implemented. For me it is also important to store ID's in the TokenModel.

+1, this would be quite useful

@NickIliev any update on this? I believe this is a very much needed feature, I've tried extending the model on my own but RadAutoCompleteTextView seems to ignore it. Adding an "id" property or something like "customProperties" of type any would do the trick.

@NickIliev like to see this feature

馃憤
@NickIliev there is a workaround until this feature is added?

I don't know how RadAutoCompleteTextView can be used for something serious without this feature :(

Any plans to have this implemented soon ? As of right now the RadAutoCompleteTextView seems pretty limited and doesn't support some basic functionality.

@Pandishpan my workaround with async search in vue:

{
    data () {
        return {
            selectedItems: [], // array of selected items (objects)
            suggestedItems: []
        };
    },
    created () {
        this.$refs.autocomplete.setLoadSuggestionsAsync((text) => {
            return new Promise(... this.$set(this, 'suggestedItems', items); // save that objects to suggestedItems
        });
    },
    methods: {
        removeToken ({ token }) { // -> tokenRemoved event
            let itemIndex = this.selectedItems.findIndex(item => item.text === token.text),
                item = this.selectedItems[itemIndex ];
            if (item ) {
                this.selectedItems.splice(itemIndex , 1);
            }
        },
        addToken ({ text }) { // tokenAdded event
            let item = this.suggestedItems.find(item => item.text === text); // find item object in suggestedItems (set before in LoadSuggestionsAsync method)
            if (item ) {
                this.selectedItems.push(item);
            }
        }
    }
}

@wendt88 Thanks, but on the scenario where you have for example Country, County/State, City selection (fields with relationship selection) ... it's becoming a real mess, especially if you want to combine the State and City into only one field.

Adding an ID field into the model as @aboganas suggested could help or allowing to pass a custom made model it's even better.

Here's more info about how to extend the token model:

Implemented in https://github.com/NativeScript/nativescript-ui-autocomplete/releases/tag/v4.1.0
@DimitarTodorov @tgpetrov @NickIliev
Does it only work with displayMode tokens? or it also works with the Plain display mode?
I don't see a way to get the selected token from the didAutoComplete event

Implemented in https://github.com/NativeScript/nativescript-ui-autocomplete/releases/tag/v4.1.0
@DimitarTodorov @tgpetrov @NickIliev
Does it only work with displayMode tokens? or it also works with the Plain display mode?
I don't see a way to get the selected token from the didAutoComplete event

I updated to the latest version of "nativescript-ui-autocomplet" (5.1.0) and now it's working fine. The event didAutoComplete contains the right data. Thanks for the great work!

Was this page helpful?
0 / 5 - 0 ratings