jQWidgets Forums

jQuery UI Widgets Forums Grid Refresh dropdownlist options

Tagged: 

This topic contains 1 reply, has 1 voice, and was last updated by  vasikgreif 11 years ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Refresh dropdownlist options #54928

    vasikgreif
    Participant

    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?

    Refresh dropdownlist options #54930

    vasikgreif
    Participant

    Please ignore this question, I noticed it works already – it seems the Ajax to get dropdown data is called everytime the dropdown is accessed…

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.