Author Topic: Help with raw select  (Read 2925 times)

sergeda

  • Newbie
  • *
  • Posts: 1
    • View Profile
Help with raw select
« on: April 15, 2014, 02:58:30 pm »
Hi. Can somebody help me with this.
I'm trying to get data from the selected raw like in demo. But it doesn't work. Alert doesn't fire at all.
Code: [Select]
        $(window).on('load', function () {
            var data = [ [1,'Exxon Mobil','339,938.0','36,130.0'],
                [2,'Wal-Mart Stores','315,654.0','11,231.0'],
                [3,'Royal Dutch Shell','306,731.0','25,311.0'],
                [4,'BP','267,600.0','22,341.0'],
                [5,'General Motors','192,604.0','-10,567.0'],
                [6,'Chevron','189,481.0','14,099.0']];

            var obj = {};
            obj.colModel = [{title:"Rank", width:100, dataType:"integer"},
                {title:"Company", width:200, dataType:"string"},
                {title:"Revenues ($ millions)", width:150, dataType:"float", align:"right"},
                {title:"Profits ($ millions)", width:150, dataType:"float", align:"right"}];
            obj.dataModel = {data:data};
            $("#grid").pqGrid( obj );
            obj.rowSelect = function (evt, obj) {
                alert('Selected');
}


});

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6298
    • View Profile
Re: Help with raw select
« Reply #1 on: April 15, 2014, 06:43:58 pm »
Grid constructor i.e. $("#grid").pqGrid( obj ) deep clones the obj so that grid can't use any property attached to obj after initialization.

Right way is to initialize the grid after attaching rowSelect callback to obj.
« Last Edit: April 19, 2014, 01:12:27 am by paramquery »