Author Topic: Dropdowns  (Read 4041 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: 6310
    • View Profile
Re: Dropdowns
« Reply #1 on: January 06, 2015, 05:24:37 pm »
Happy new Year to you as well.

Please check the Shipping Via column in this demo http://paramquery.com/pro/demos/editing_custom

Possible formats of JSON data are mentioned in the API

http://paramquery.com/pro/api#option-column-editor

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: 6310
    • View Profile
Re: Dropdowns
« Reply #3 on: January 07, 2015, 07:05:44 pm »
Please check ShipVia column in http://paramquery.com/pro/demos/editing_custom

editor: {
          type: 'select',                   
          options: [{ '': '' }, { 'SE': 'Speedy Express' }, { 'UP': 'United Package' }, { 'FS': 'Federal Shipping'}]
}

or

editor: {
          type: 'select',                   
          valueIndx: 'id',
          labelIndx: 'text',
          options: [{ id: 'SE', text: 'Speedy Express' }, { id: 'UP', text: 'United Package' }, {id: 'FS', text: 'Federal Shipping'}]
}
« 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: 6310
    • View Profile
Re: Dropdowns
« Reply #5 on: January 08, 2015, 10:08:01 pm »
your callback is asynchronous function, you haven't mentioned valueIndx, labelIndx in the editor definition and your render callback is incorrect for the JSON format.

Please check the ShipVia column in this example:

http://paramquery.com/pro/demos/editing_custom2