Author Topic: Re-selecting and opening pqselect from cell when cell is clicked  (Read 1950 times)

kshipra

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 94
    • View Profile
In grid with pqselect multiple items are getting selected and displayed in cell with "," separator. On cell selection the pqselect should be opened with items checked (selected) from cell text. I am trying to do this in cellClick function but it is not working. I am not sure what I am missing?

cellClick: function (evt, ui) {
               
                console.log(ui.dataIndx);
                console.log(ui.cellData);
                if (ui.dataIndx == 'ValidationClassifications') {
                    console.log("ui.rowData");
                    console.log(ui.rowData);
                    if (ui.rowData) {
                        var rowIndx = ui.rowIndx,
                       colIndx = ui.colIndx,
                       dataIndx = ui.dataIndx,
                       cellData = ui.rowData[dataIndx];
                        console.log(cellData);
                    }
                   /* ui.$cell.find("select").val(cellData.split(","));
                    ui.$cell.find("select").pqSelect({
                        multiplePlaceholder: 'Select Multiple',
                        checkbox: true //adds checkbox to options
                    }).pqSelect("open");*/
                }}

kshipra

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 94
    • View Profile
Re: Re-selecting and opening pqselect from cell when cell is clicked
« Reply #1 on: June 03, 2017, 08:22:36 pm »
Figured out. my values were not same as text when re-initializing it back so pq-select was not setting it back. I also do not need cellclick event.

 editor: {
                    type: 'select',
                    attr: "multiple='multiple'",
                    init: function (ui) {
                        console.log("ui.cellData init");
                        console.log(ui.cellData);
                        var val = ui.cellData == null ? "" : ui.cellData;
                        var $sel = ui.$cell.find("select");

                        if (val != "") {
                            var optValues = val.split(",");
                            var trimOptValues = [];

                            for (var i = 0; i < optValues.length; i++)
                            {
                                trimOptValues.push(optValues.trim());
                            }

                            $sel.val(trimOptValues);
                        }

                        $sel.pqSelect({
                            checkbox: true,
                            multiplePlaceholder: 'Select Multiple',
                            maxDisplay: 5
                        });
                    },
                    getData: function (ui) {
                        //var val = ui.$cell.find("select").val();
                        // alert("hi");
                       // console.log("getdata");
                        var txt = ui.$cell.find("select").find("option:selected");
                        console.log(txt);
                        var selected = [];
                        for (var i = 0, l = txt.length; i < l; i++) {
                            selected.push(txt.textContent);
                        }
                        return selected.join(', ');
                    },