ParamQuery grid support forum

General Category => Help for ParamQuery Grid (free version) => Topic started by: jjestrellaa on August 08, 2017, 08:12:51 pm

Title: examples for DB options for a select menu in the toolbar
Post by: jjestrellaa on August 08, 2017, 08:12:51 pm
are there any examples for getting the values for a 'SELECT' item in the toolbar from the database?

currently have this

 toolbar: {
      items[
                 {
                    type:'select',
                    options:[ { "value1": "Description1" },
                                    { "value2": "Description2" }, 
                                ]
                 }
              ]
}

want something like this
 toolbar: {
      items[
                 {
                    type:'select',
                    options: function(){
                                var values = []
                                 $.getJSON("my/url", data, function(response){
                                                     $.each(response, function(index,item){
                                                               values.push(item)
                                                                }
                                                }
                                   }
              ]
}
Title: Re: examples for DB options for a select menu in the toolbar
Post by: jjestrellaa on August 09, 2017, 02:19:50 am
This can be closed. Just followed standard jquery:

 toolbar: {
      items[
                 {
                    type:'select',
                    options:
                                 $.getJSON("my/url", data, function(response){
                                                     $.each(response, function(index,item){
                                                              $('.selector').append($('<option>', {
                                                             value: item.Name,
                                                              text: item.Label
                                    }));
                                                                }
                                                }
                                   
              ]
}