Author Topic: setSelection changes page  (Read 2062 times)

JSPetit

  • Newbie
  • *
  • Posts: 3
    • View Profile
setSelection changes page
« on: September 20, 2018, 12:25:22 am »

The setting:

ParamQuery Pro v3.3.2

Code: [Select]
        var obj = {
            scrollModel: { autoFit: true },
            datatype: "json",
            showTop: false,
            numberCell: { show: false },
            selectionModel: { type: 'row', fireSelectChange: true },
            dataModel: {
                data: []
            },
            pageModel: { type: "local", rPP: 20, strRpp: "{0}", strDisplay: "{0} to {1} of {2}" },
            refresh: _refreshSearchGrid,
            colModel: cols,
            hoverMode: 'row',
            selectChange: _searchGridSelectionChange
        };

        _self.SearchGridSelector = "[id='" + context + "'] div[controlname='" + grid.GridName + "']"
        _self.SearchGrid = $(_self.SearchGridSelector).pqGrid(obj);



    };

    function _refreshSearchGrid(refreshEvent, ui) {
        var trs = _self.SearchGrid.find("tr.pq-grid-row");
        trs.mousedown(function (mousedownEvent){
            if (mousedownEvent.which == 3)
        {
                var index = $(this).attr("pq-row-indx");
                var isSelected = _self.SearchGrid.pqGrid("selection",
                    { type: 'row', method: 'isSelected', rowIndx: index }
                );
                if (!isSelected) {
                    _self.SearchGrid.pqGrid("setSelection", { rowIndx: index });
                }                       
        }
        });       
    }

I also use JQuery's contextmenu on the grid container.

What happens is that when I right-click on row 2, it changes to page 2, row 3 page 3, row 4 etc...

The culprit seems to be the line

Code: [Select]
_self.SearchGrid.pqGrid("setSelection", { rowIndx: index });
For some reason, this selects the row as intended, but it also change the page to the row index.

Strange behaviour...

I'm still looking for an extra parameter, but if you have an answer, please do no hesitate to share it with me.




JSPetit

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: setSelection changes page
« Reply #1 on: September 20, 2018, 12:59:20 am »
Found it...

I changed rowIndx to rowIndxPage
Code: [Select]

        var isSelected = _self.SearchGrid.pqGrid("selection",   { type: 'row', method: 'isSelected', rowIndxPage: index }
        if (!isSelected) {
                    _self.SearchGrid.pqGrid("setSelection", { rowIndxPage: index });
                } 

also, bear in mind that index has to be a INT, otherwise "selection" with rowIndxPage will return undefined, at least in 3.3.2.


Code: [Select]
        var pqRowIndx = $(this).attr("pq-row-indx");
                var index = parseInt(pqRowIndx);