Here is an email thread where Andrew and I brainstorm possible solutions. Just cleaning my inbox.
Andrew Goodale (Wingspan)
Feb 24
to me
I think that would be more deterministic, although I'm not sure what you mean by "manage the datasource by hand".
I know that kendo's combo tries to be smart, making secret requests for data when the value is set. I'm not a fan of magic like that, but I understand we need to work within what they do. Maybe the best choice, for "_Kendo_ComboBox", is to always pass the ID and let Kendo do its thing.
On Mon, Feb 24, 2014 at 9:43 AM, Dustin Getz (Wingspan) wrote:
so in both cases, we're going to bypass kendoCombo.value() and use kendoCombo.text() directly, and manage the datasource by hand?
On Mon, Feb 24, 2014 at 9:41 AM, Andrew Goodale (Wingspan) wrote:
You're not going to be able to have a library that dictates the server's data design choices - at least I don't think.
I guess what I'm trying to say is that the ComboBox would be happier if it didn't have to worry about this. Can we just externalize the whole issue, such that the ComboBox:
- Always treats "value" as an opaque thing.
- When it needs to render text for the value, it calls a function that's passed in. So the logic to determine how to display values is managed by the owner of the combo. Thus, whether the data is flat, joined, or whatever, the combo doesn't care.
On Mon, Feb 24, 2014 at 9:24 AM, Dustin Getz (Wingspan) wrote:
I am not sure how that would look. Can you elaborate a little more?
To recap the valueAs stuff:
if its always valueAsId, the object shapes are consistent (nothing joined) and always result in a datastore fetch. Thus all the code goes through the same "happy path" and there is more opportunity for abstraction. valueAsOption is the inline optimization which costs opportunities for abstraction because the business logic becomes coupled to the shape of the data, what is joined in and to which depth. So you couldn't build an AutoCrudApp for example.
On Fri, Feb 21, 2014 at 8:32 AM, Andrew Goodale wrote:
It's a little unusual. An alternative would be to allow an optional "valueRenderer" function, which would allow folks to handle any type of value. I can't remember all the reasons why a combo cares about the ID vs. Object issue, but it seems like it keeps the combo simpler to allow it to treat the value as opaque and let folks customize the rendering of the value.
If I was building a combo box from scratch, I would have "value" and "valueRender" props instead of "value", "idField" and "displayField".
AHG
On 20 Feb 2014, at 22:09, Dustin Getz (Wingspan) wrote:
I'm going to make the mode an explicit prop like mode={Modes.ValueAsId}
.
If no mode is passed, it can default to "figure it out". I also am going to
add a console.warn every time this happens.
Can you think of any reason not to do this?