ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: kshipra on June 03, 2017, 07:03:49 am

Title: Re-selecting and opening pqselect from cell when cell is clicked
Post by: kshipra on June 03, 2017, 07:03:49 am
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");*/
                }}
Title: Re: Re-selecting and opening pqselect from cell when cell is clicked
Post by: kshipra 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(', ');
                    },