Author Topic: examples for DB options for a select menu in the toolbar  (Read 2774 times)

jjestrellaa

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 15
    • View Profile
examples for DB options for a select menu in the toolbar
« 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)
                                                                }
                                                }
                                   }
              ]
}

jjestrellaa

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: examples for DB options for a select menu in the toolbar
« Reply #1 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
                                    }));
                                                                }
                                                }
                                   
              ]
}