-
Notifications
You must be signed in to change notification settings - Fork 346
selectmenu or select2 as field types #141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I guess the problem is the same as in the ticket #72 |
Thanks, that suggestion worked immediately. Also thanks for immediate response :) |
Please, checkout this SO answer http://stackoverflow.com/questions/19899983/how-to-update-data-in-select2-dropdown-using-ajax |
Not really. The problem is the same if I use built-in select control. The select is built with values that were present when I created the jsgrid, not with ones that were present when I clicked the + icon to add a new row. Basically, if I call $("#mygrid").jsGrid("reset"); I'd like the selects to rebuild with current values in the items array. |
Call |
It would seem that jsgrid makes a deep-copy of the items array. I have just debugged and render does in fact call _createSelect, but the items array is not changed. I suppose I'll need to re-declare fields through option command? |
The options are not deeply extended. But the fields are initialized by config provided. Try to assing fields option again. |
OK, final, working solution: So I tried destroying the widget and creating it again. This works as expected in all scenarios I tried. Also, to answer your question: I can't build the field options ahead because the grid is basically a detail for another master. Each item in master data set has different options for this particular field. So I have to load them and assign them to the field in the grid. Thanks again for all the help. This is rare. I think I chose the right grid for my project :) |
Thank you! |
If you can find any worth in this: here's what I did for select2. The field also adds another field attribute, called imgField. As with valueField and textField, this one points to the items array and displays the image in the select2 widget. Well, since the code is pretty much the same all around, perhaps target widget could be made a parameter as well so that multiple field types wouldn't be necessary. If you find this useful, feel free to include it in your excellent widget :) Code:
|
Perfect! Thank you! |
It's worth noting that implementing the Select2 like this gets around the pervasive problem of materialize nuking selects in the jsgrid. |
Trying this grid out to see if it suits my needs. Tried to declare custom fields for select that would handle presentation via jQuery UI's selectmenu or with the excellent Select2 component.
Looking at sample code, I thought to just take the declaration for select field and modify it only such that _createSelect function would return e.g. $result.select2() (besides the obvious renamings, of course).
However, this results in no control being rendered. Is what I'm trying to do even possible?
The text was updated successfully, but these errors were encountered: