Skip to content
This repository has been archived by the owner on Jul 26, 2022. It is now read-only.

Suggestion: support array of objects as data source #62

Open
mnantel opened this issue Sep 19, 2019 · 4 comments
Open

Suggestion: support array of objects as data source #62

mnantel opened this issue Sep 19, 2019 · 4 comments

Comments

@mnantel
Copy link

mnantel commented Sep 19, 2019

Greetings,

Project works great! I am not very experience with JS, but what I was trying to do with this code was to use it to select an item within an array of objects, whereas the searched properties might be distinct than property bound to vmodel. As it stands, is my assumption correct that this is only for simple arrays of strings?

@audetcameron
Copy link

audetcameron commented Oct 16, 2019

you should be able to use the serializer

 :data="associative_array"
 :serializer="myvar=> myvar.keywithstringfromassociative_array"

@mattzollinhofer
Copy link

If we understand you right, this should already be supported.

@ozziest
Copy link

ozziest commented Feb 19, 2021

@alexurquhart,

I have an object array and I want to search it with different properties at the same time. I guess, there is not any way to do that now, isn't it? When I use a serializer, it searches only in the serialized array.

@audetcameron
Copy link

@alexurquhart,

I have an object array and I want to search it with different properties at the same time. I guess, there is not any way to do that now, isn't it? When I use a serializer, it searches only in the serialized array.

you could maybe modify your data strings from your API response (or after the response before you set the value to your v-model"
example :
your response is

{[
{
    'username':'my_username', 
    'first_name':'my_first_name'
},
    'username':'your_username', 
    'first_name':'your_first_name'
}
]} 

use javascript to convert the strings to something like this. (note | is just a character used to separate data in your string) you can use anything you want.

{[
{'my_username | my_first_name'},
{'your_username' | your_first_name}
]} 

then use the custom separator character | to modify the display using a computed property on the "query" v-model data. therefore it only shows my_username but still queries the other data.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants