This is a migrated thread and some comments may be shown as answers.

How to use ViewModel when retrieving data from a SQLite database.

1 Answer 328 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Rajesh
Top achievements
Rank 1
Rajesh asked on 04 Jan 2018, 05:20 AM

Hi,

I am interested in using your AutoComplete Control where data is bound to a ViewModel and it is retrieved from a SQLite database following this link

https://docs.telerik.com/devtools/xamarin/controls/autocomplete/features/autocomplete-data-binding#example

Can you please let me know if this is possible with an example.

1. The data for the view model is retrieved from a Sqlite database in Xamarin Forms (ios or Android)

2. The data is pulled in an async method from the database and the volume of data will vary.

3. I need to have 2 columns for every autocomplete control viz. ID and Name. (ID is the unique id for the data and is saved in the database when selected and Name is the friendly name displayed in the autocomplete control.

4. How should this be executed when i have at least 7 autocomplete controls in a single Content page. Should all be executed in the onAppearing Event.

Thanks,

Rajesh.

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 09 Jan 2018, 08:07 AM
Hello Rajesh,

Thank you for your interest in RadAutoComplete for Xamarin.

I will go straight to your questions:

1 and 2: RadAutocomplete could be bound to a list of business objects via a ViewModel, the actual data could be retrieved in various ways including SQLite database. I have created a sample project to demonstrate how you could populate the control after getting the items asynchronously - the example is based on the following tutorial and sample app: Xamarin.Forms Local Databases.

3. In the attached example I've used a class named CategoryItem with a unique ID marked with PrimaryKey and AutoIncrement attributes like this:

public class CategoryItem
{
    [PrimaryKey, AutoIncrement]
    public int CategoryID { get; set; }
    public string Category { get; set; }
}

4. This seems as a straightforward solution, however it's more of application logic and as I am not aware of the exact setup and the requirements you have, I'd prefer not giving recommendations on this.

Let me know if I can assist with anything else.

Regards,
Yana
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
AutoComplete
Asked by
Rajesh
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or