jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Refresh dropdownlist options
Tagged: DropDownList
This topic contains 1 reply, has 1 voice, and was last updated by vasikgreif 11 years ago.
-
Author
-
I have functional dropdownlist (thanks to Dimitar and this thread: http://www.jqwidgets.com/community/topic/value-displayname-combo-in-dropdownlist/).
Now, I’m allowing users to add new dropdown options. This is done with custom Ajax call. After the call is finished, I would need to refresh the dropdown values.
My code is (pasting only the important parts):
var dropDownListSource = { datatype: "json", datafields: [ { name: 'name' }, { name: 'term_id' } ], id: 'id', url: Ajax.ajaxurl, mtype: 'POST', data: { action: 'get_taxonomy_terms' } }; var dropdownListAdapter = new $.jqx.dataAdapter(dropDownListSource, { autoBind: true, async: false }); ..... ..... ..... columns: [ { text: 'Category', columntype: 'dropdownlist', datafield: 'term_id', displayfield: 'category', width: 100, createeditor: function (row, value, editor) { editor.jqxDropDownList({ source: dropdownListAdapter , displayMember: 'name', valueMember: 'term_id' }); } }, ] ...... ...... $("#add_taxonomy_term").validate({ submitHandler: function (form) { var sData = $(form).serialize(); $.ajax({ url: Ajax.ajaxurl, async: true, type: 'POST', data: sData, success: function (data) { var result = $.parseJSON(data); console.log(result); if (result.status == 'error') { $(form).append('<div class="alert alert-danger">' + result.message + '</div>'); } if (result.status == 'success') { $('<tr data-id="'+ result.term_id +'"><td>'+result.name+'</td><td><a href="#">'+Ajax.delete+'</a></td></tr>').insertAfter('#budget-categories tr:last'); HERE I NEED TO REFRESH THE DROPDOWN } } }); } });
What method should I call to refresh the dropdown options?
Please ignore this question, I noticed it works already – it seems the Ajax to get dropdown data is called everytime the dropdown is accessed…
-
AuthorPosts
You must be logged in to reply to this topic.