Author Topic: Dropdowns  (Read 3741 times)

rgorantla

  • Pro Deluxe
  • Jr. Member
  • *
  • Posts: 88
    • View Profile
Dropdowns
« on: January 05, 2015, 09:11:40 pm »
Hi,

Happy New Year!

I have JSON data returning text and value - how do i display text in dropdowns ? I also need value of it but hidden

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 5791
    • View Profile
Re: Dropdowns
« Reply #1 on: January 06, 2015, 05:24:37 pm »
[ Only Pro members may read this post. ]

rgorantla

  • Pro Deluxe
  • Jr. Member
  • *
  • Posts: 88
    • View Profile
Re: Dropdowns
« Reply #2 on: January 07, 2015, 07:09:31 am »
Hi,

Thank you !

could you please provide me an example for JSON data
« Last Edit: January 07, 2015, 07:38:32 am by rgorantla »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 5791
    • View Profile
Re: Dropdowns
« Reply #3 on: January 07, 2015, 07:05:44 pm »
[ Only Pro members may read this post. ]
« Last Edit: January 07, 2015, 07:22:51 pm by paramquery »

rgorantla

  • Pro Deluxe
  • Jr. Member
  • *
  • Posts: 88
    • View Profile
Re: Dropdowns
« Reply #4 on: January 07, 2015, 11:12:14 pm »
Hi,

Please see the code below :  I still dont see the values.. Can you please correct whats wrong in this?

function clientsauto() {
        var jst;
        $.getJSON(clientslink, function (data) {
            var o = _.object(_.map(data, function (x) { return [x.Value, x.Text] }));
            jst = JSON.stringify(data);
            console.log(jst); // jst has [{"Text":"Select a Client","Value":"0"},{},{..}]
            return jst;
        });       
    }

 editor: {
                    type: "select",
                    options: clientsauto,
                    getData: function (ui) {
                        return ui.$cell.find("select").val()
                    }

                },
                render: function (ui) {
                    var options = ui.column.editor.options,
                        cellData = ui.cellData;
                    for (var i = 0; i < options.length; i++) {
                        var option = options;
                        if (option[cellData]) {
                            return option[cellData];
                        }
                    }
                },

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 5791
    • View Profile
Re: Dropdowns
« Reply #5 on: January 08, 2015, 10:08:01 pm »
[ Only Pro members may read this post. ]