ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: rgorantla on January 05, 2015, 09:11:40 pm

Title: Dropdowns
Post by: rgorantla 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
Title: Re: Dropdowns
Post by: paramvir 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
Title: Re: Dropdowns
Post by: rgorantla on January 07, 2015, 07:09:31 am
Hi,

Thank you !

could you please provide me an example for JSON data
Title: Re: Dropdowns
Post by: paramvir 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'}]
}
Title: Re: Dropdowns
Post by: rgorantla 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];
                        }
                    }
                },
Title: Re: Dropdowns
Post by: paramvir 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