material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

Auto-complete dataSource

Open k010 opened this issue 11 years ago • 12 comments

Hey guys thanks for the new component !!. Is posible to pass to the dataSource an array of objects ? Eg:

[
  {
    value: 'es_AR',
    name: 'Spanish'
  },
  {
    value: 'en_US',
    name: 'English'
  }
]

Thanks !

k010 avatar Nov 24 '15 20:11 k010

This would be more consistent with the SelectField. I often want to get an identifier from a dropdown list instead of a plain text. :+1:

jgoux avatar Nov 25 '15 08:11 jgoux

I agree, this would be useful.

oliviertassinari avatar Nov 25 '15 08:11 oliviertassinari

For info, react-toolbox takes a dataSource in the form { identifier1: displayedText1, identifier2: displayedText2, ... }. I think the best way would be to accept either an array of strings, or an object in this form when you want to get an underlying value. Or maybe the same array of object that SelectField accept to be consistent with it ?

jgoux avatar Nov 25 '15 08:11 jgoux

@jgoux That form lacks flexibility, you can't have Objects, Boolean, Regex, and a lot more as object property identifier. and they have very valid use cases. I'd go with the { value, payload } style already applied to select field.

alitaheri avatar Nov 25 '15 08:11 alitaheri

@k010 @subjectix , I like the idea. I am going to work on it and make it consistent with SelectField. This component is still quite new, I'd love to see more contribution from others that makes it more flexible. :)

yongxu avatar Nov 26 '15 03:11 yongxu

text-value list dataSource support #2286

yongxu avatar Nov 27 '15 07:11 yongxu

+1 @yongxu thanks !!!

k010 avatar Nov 30 '15 14:11 k010

#2286 made this possible.

alitaheri avatar Dec 09 '15 17:12 alitaheri

Hi. Is there any documentation on this?

I was checking here: http://www.material-ui.com/#/components/auto-complete but couldn't see anything relating this particular dataSource syntax.

arcseldon avatar Dec 24 '15 17:12 arcseldon

There still doesn't seem to be documentation of what can be passed as a datasource beyond an array of strings.

Sigfried avatar Apr 03 '17 15:04 Sigfried

@Sigfried What about the ExampleDataSources?

oliviertassinari avatar Apr 03 '17 15:04 oliviertassinari

I just noticed those. They definitely give better hints. I think what I want is in the third example, but it takes a little time to parse: I guess if I want displayed text to be different from the saved value I need a dataSourceConfig.

Yeah, the examples should do it for me. I wasted some time trying to find a list of properties I could send to dataSource (or dataSourceConfig). Maybe there's some way to indicated that the places to look are in the examples and the source code, there's no api doc for those specific fields.

Sigfried avatar Apr 03 '17 16:04 Sigfried