Author Topic: ClickRow works but RowRightClick doesn't?  (Read 4438 times)

ridwanhabbal

  • Newbie
  • *
  • Posts: 18
    • View Profile
ClickRow works but RowRightClick doesn't?
« on: July 24, 2015, 06:06:38 pm »
Hi,

I have created the following sample based on the downloaded package from the sight. it's all fine but rightclick event is not getting fired

Please check line: $("#grid_table").on( "pqgridrowrightclick", function( event, ui ) {alert();} );
$("#grid_table").pqGrid({
            rowRightClick: function( event, ui ) {
                  //alert(ui.rowIndx);
                  //alert(ui.rowIndxPage);
                  var data = ui.dataModel.data[ui.rowIndx];
                  alert("Rank is: "+data[0]);
            }
         });


function changeToGrid(that) {
            var tbl = $("table.fortune500");
            var obj = $.paramquery.tableToArray(tbl);
            var newObj = { width: 700, height: 400, numberCell: false, title: "Grid From Table", resizable: false, editable:false };
            newObj.dataModel = { data: obj.data, rPP: 20, paging: "local" };
            newObj.colModel = obj.colModel;
         var columns = [
            { title: "Rank", width: 100, dataIndx: "0", hidden: true },
            { title: "Company", width: 130, dataIndx: "1" },
            { title: "Revenues ($ millions)", width: 190, dataIndx: "2" },
            { title: "Profits ($ millions)", width: 100, dataIndx: "3", align: "right" },
            { title: "Links", width: 100, dataIndx: "4", align: "right" },
         ];
         newObj.colModel = columns;
         newObj.dataModel = { data: obj.data, rPP: 20, paging: "local"};
            $("#grid_table").pqGrid(newObj);
         $("#grid_table").pqGrid({
            rowClick: function( event, ui ) {
                  //alert(ui.rowIndx);
                  //alert(ui.rowIndxPage);
                  var data = ui.dataModel.data[ui.rowIndx];
                  alert("Rank is: "+data[0]);
            }
         });
         $("#grid_table").on( "pqgridrowrightclick", function( event, ui ) {alert();} );
            $(that).val("Change Grid back to Table");
            tbl.css("display", "none");
        }

Thanks and Regards,
Ridwan

ridwanhabbal

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: ClickRow works but RowRightClick doesn't?
« Reply #1 on: July 25, 2015, 06:33:30 am »
Hi everybody
Any suggestion? please assist?
Thanks
Ridwan

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6265
    • View Profile
Re: ClickRow works but RowRightClick doesn't?
« Reply #2 on: July 25, 2015, 07:35:49 pm »
rowrightclick is not in the API of basic version.

http://paramquery.com/api

you could use this:

$(".pq-grid").on("contextmenu", ".pq-grid-row", function(evt){
  alert("right click");
});

http://jsfiddle.net/7jnf6s3t/103/
« Last Edit: July 25, 2015, 07:42:13 pm by paramquery »

ridwanhabbal

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: ClickRow works but RowRightClick doesn't?
« Reply #3 on: July 27, 2015, 02:53:05 am »
Really thanks....
But how can I access the row data. I've been doing something like
//alert(ui.rowIndx);
                  //alert(ui.rowIndxPage);
                  var data = ui.dataModel.data[ui.rowIndx];
                  alert("Rank is: "+data[0]);
for rowCLick
Could you please help?

Thanks

ridwanhabbal

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: ClickRow works but RowRightClick doesn't?
« Reply #4 on: July 27, 2015, 01:22:04 pm »
Could some one assist me plz

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6265
    • View Profile
Re: ClickRow works but RowRightClick doesn't?
« Reply #5 on: July 27, 2015, 01:35:47 pm »
$(".pq-grid").on("contextmenu", ".pq-grid-row", function(evt){
          //alert("right click");
            var rowIndx = $(this).attr("pq-row-indx");
            alert(data[rowIndx][0]);
            return false;
        });   

http://jsfiddle.net/7jnf6s3t/104/