jQWidgets Forums
jQuery UI Widgets › Forums › Lists › DropDownList › jqxgrid column dropdownlist lookup
This topic contains 5 replies, has 2 voices, and was last updated by edwardw 12 years, 1 month ago.
-
Author
-
Hi
I’ve made a lot of progress with jqwidgets. I’ve searched the forums and documentation. I’m still stumped as to how to populate a dropdownlist column of a jqxgrid with values from small lookup tables in my MySQL database. I’d like to use json with a DataAdapter if possible. Would you be able to show me a sample? I’ve been able to get a single dropdownlist to populate. If a dropdownlist is within a grid it appears I need to use createeditor function. I see how to use this with local data but how can I make it work through a lookup table.
Thanks
Hi,
For binding the DropDownList to MySQL, see: http://www.jqwidgets.com/jquery-widgets-demo/demos/php/dropdownlist.htm?web
The above approach uses a jqxDataAdapter for binding the widget. You can then define that jqxDataAdapter in the Grid column’s createeditor callback function and set the DropDownList’s source property to point to the new instance of jqxDataAdapter. That will override the default data source prepared for the editor and it will use the new one.
Another very useful sample is that: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/gridkeyvaluescolumnwitharray.htm?web. It illustrates how to create a DropDownList editor with external data souce and how to set up the column’s displayfield and datafield properties. By setting the displayfield and datafield properties you actually make each cell in the column to have displayed text and underlying value. The displayMember and valueMember properties of the DropDownList editor are set, too. The displayMember of the DropDownList specifies the displayed item’s label, the valueMember specifies the item’s value.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Hi Peter
Thank you so much! I’ve combined the 2 examples and I’m getting values in my dropdownlist. I have 2 more questions.
1. I have to click the dropdown a few times. It won’t populate immediately. Sometimes I have to click the dropdown in
another row for the values to appear.
2. I have a lot of different dropdowns which are populated by small MySQL tables. How can I pass a value into my
dropdownlist.php lookup file so that I can use one file to do the Select * for multiple tables?Thanks again
Edward
hi Peter
I tried to connect my dropdownlist to a dataadapter using jsonp (in order to send the table name as a variable). I had no success. Will a dropdownlist/dataadapter work with jsonp ?
Hi,
JSONP is already supported and we also have demos about it. Example: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxcombobox/remotesearch.htm?web and http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxlistbox/remotesearch.htm?web and http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxinput/remoteautocomplete.htm?web. All of the demos use Binding through jqxDataAdapter so you can use the same approach with jqxDropDownList, too. Just set its “source” property to point to the jqxDataAdapter instance.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Thank you Peter. This works.
-
AuthorPosts
You must be logged in to reply to this topic.