Author Topic: Populate select list from DB  (Read 12060 times)

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 5642
    • View Profile
Re: Populate select list from DB
« Reply #15 on: August 24, 2018, 10:34:36 am »
[ Only Pro members may read this post. ]

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 315
    • View Profile
Re: Populate select list from DB
« Reply #16 on: August 24, 2018, 03:12:42 pm »
Was a bit quick there... :)
Still having issues with the format of the json response. Currently I have:

Code: [Select]
{ {"country": [{"country":"aaa"}, {"country":"bbb"}]}, {"city": [{"city":"ccc"}, {"city":"ddd"}]} }
Won't work...guess format is wrong?

Also, how can I use a variable when assigning the options like:

Code: [Select]
arrCol.forEach(function (value) {
  column = grid.getColumn({ dataIndx: value });
  column.filter.cache = null;
  column.filter.options = response.[_USE_VARIABLE_VALUE_];
});

« Last Edit: August 24, 2018, 03:14:30 pm by queensgambit9 »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 5642
    • View Profile
Re: Populate select list from DB
« Reply #17 on: August 24, 2018, 03:29:52 pm »
[ Only Pro members may read this post. ]
« Last Edit: August 24, 2018, 05:36:27 pm by paramquery »

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 315
    • View Profile
Re: Populate select list from DB
« Reply #18 on: August 24, 2018, 06:03:01 pm »
Thanks. Adjusted JSON response, but still can't get it to work...

Code: [Select]
var arrCol = ["col1", "col2"];
    var grid = this;
    $.getJSON("/php/data.php", "cols=" + JSON.stringify(arrCol), function (response) {
        // all keys looks correct in response           
        for(var key in response){
            grid.getColumn({ dataIndx: key }).filter.options = response[ key ];
        }
       
        grid.refreshHeader();
    });

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 5642
    • View Profile
Re: Populate select list from DB
« Reply #19 on: August 24, 2018, 07:59:13 pm »
[ Only Pro members may read this post. ]
« Last Edit: August 24, 2018, 08:03:22 pm by paramquery »

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 315
    • View Profile
Re: Populate select list from DB
« Reply #20 on: August 24, 2018, 08:12:45 pm »
No error in console. The options are assigned when I check the filter options using the debugger in console.
But the options do not appear.
Response is attached.
« Last Edit: August 24, 2018, 08:19:55 pm by queensgambit9 »

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 315
    • View Profile
Re: Populate select list from DB
« Reply #21 on: August 27, 2018, 01:39:38 am »
Update: Seems to be working now, didn't have the
Code: [Select]
column.filter.cache = null;...
Thanks for your help.
« Last Edit: August 27, 2018, 01:45:20 am by queensgambit9 »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 5642
    • View Profile
Re: Populate select list from DB
« Reply #22 on: August 27, 2018, 10:43:02 am »
[ Only Pro members may read this post. ]

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 315
    • View Profile
Re: Populate select list from DB
« Reply #23 on: August 27, 2018, 12:21:04 pm »
You are correct, was using 5.1.0.
« Last Edit: August 27, 2018, 12:42:14 pm by queensgambit9 »