Author Topic: editor is select, the rendering value not is text  (Read 1639 times)

kevin

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 3
    • View Profile
editor is select, the rendering value not is text
« on: October 19, 2021, 08:45:44 am »
Hello,

When the editor is select, the rendering value does not use text, but uses value:
https://www.paramquery.com/pro/demos/edit_multiline
Code: [Select]

    $(function () {
        var colM = [
            {
                title: "Auto size editor (Enter for new lines)", width: 200, dataIndx: "ShipAddress1",
                editor: {
                    type: "select",
options:[{'value1':'text 1'},{'value2':'text 2'}],
}
            },
            {
                title: "Auto size editor (Alt-Enter for new lines)", width: 200, dataIndx: "ShipAddress2",
                editor: {
                    type: "textarea"
                }
            },
            {
                title: "Manually resizable editor", width: 200, dataIndx: "ShipAddress3",
                editor: {
                    type: "textarea",
                    attr: "rows=8 cols=58",
                    style: "resize:both;"
                },
                editModel: {
                    saveKey: '' //disable or set it to some other key code to free up use of Enter key for line breaks.
                }
            }
        ];
        var dataModel = {
            location: "remote",
            dataType: "JSON",
            method: "GET",
            url: "/content/invoice.json",
            getData: function (response) {
                response.data.forEach(function (rd) {
                    //make ShipAddress multiline text.
                    rd.ShipAddress1 = rd.ShipAddress2 = rd.ShipAddress3 = rd.ShipAddress + "\n" + rd.ShipCity + "\n" + (rd.ShipRegion || "") + "\n" + rd.ShipPostalCode;
                })
                return response;
            }
        }
        $("div#grid_custom_editing").pqGrid({
            title: "Shipping Orders",
            dataModel: dataModel,
            colModel: colM,
            autoRow: true,
            scrollModel: { autoFit: true },
            columnTemplate: {
                valign: 'center'
            },
            create: function (evt, ui) {
                this.widget().pqTooltip();
            },
            editModel: {
                clicksToEdit: 1,
                keyUpDown: false
            },
            numberCell: { show: false },
            resizable: true
        });
    });

Thank you.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6313
    • View Profile
Re: editor is select, the rendering value not is text
« Reply #1 on: October 19, 2021, 11:23:43 pm »
Please check this example for select type editor: column "Shipping Via", valueIndx and labelIndx also need to be defined.

https://paramquery.com/pro/demos/editing_custom

kevin

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: editor is select, the rendering value not is text
« Reply #2 on: October 20, 2021, 05:17:30 am »
Refer to this document: https://paramquery.com/pro/api#option-column-editor,
1. value label pairs,options :array of associative value label pairs e.g., [ { 'CB01': 'Mark' }, { 'CB02': 'Robert' }, ... ], valueIndx and labelIndx how to define?

2. JSON data :if mapIndices not define ,render is still incorrect
Code: [Select]
editor: {
type: 'select',
//json arrays
valueIndx: "value",
labelIndx: "text",
//mapIndices: { "text": "ShipVia", "value": "ShipViaId" },
options: [
         { "value": "SE", "text": "Speedy Express" },
         { "value": "UP", "text": "United Package" },
         { "value": "FS", "text": "Federal Shipping" }
]
        /* key:value pairs
       options: [
{ "SE": "Speedy Express" },
        { "UP": "United Package" },
        { "FS": "Federal Shipping" }
    ]
    */
},
« Last Edit: October 20, 2021, 06:36:00 am by kevin »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6313
    • View Profile
Re: editor is select, the rendering value not is text
« Reply #3 on: October 20, 2021, 11:36:05 am »
Ok, sorry for my previous reply.

In your case, column.render callback has to be implemented to display corresponding text value.

Please check ShipVia2 column in the same example: https://paramquery.com/pro/demos/editing_custom

kevin

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: editor is select, the rendering value not is text
« Reply #4 on: October 20, 2021, 12:51:47 pm »
Thanks your reply, it works. but in my grid more than 10 such columns.  expect to fixed in next version.
Thanks very much!

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6313
    • View Profile
Re: editor is select, the rendering value not is text
« Reply #5 on: October 20, 2021, 01:00:31 pm »
In that case a common object with render implementation can be defined and all the columns can be extended from that common object.