Author Topic: rowSelect is not working..  (Read 3142 times)

bsolteam

  • Pro Deluxe
  • Full Member
  • *
  • Posts: 107
    • View Profile
rowSelect is not working..
« on: July 18, 2014, 07:21:16 pm »
Hi ,

I am facing one issue in my param query grid. I have a requirement like on selection of any row two components on the screen should be disabled.
I tried a lot with different param query function but still my code is not working.

My code is

$(function () {
   
   
   


     var colModel = [
                      
             { title: "", width: '5%', dataType: "bool", align: "center",type:'checkBoxSelection',
                  dataIndx:'state'},
             
                    { title: "Vessel Name", width: "95%", dataType: "string",align: "left",dataIndx:"vsl_name"
                           },       
             
                ];
       
     var dataModel = {
              location: "remote",
              dataType: "JSON",
              method: "GET",
              getUrl: function () {
             
             var obj = {
                    url: "getvesselname",
                   
             };
           
             return obj;
             },
            getData: function (response) {
             
              return { data: response.data };
              $("#grid_json").pqGrid("refreshDataAndView");
              }
          };
        
   
         var obj = {
               height:300,
               numberCell:false,
                  editable: false,
                  resizable:false,
               sortable:false,
                columnBorders: true,
                  scrollModel:{autoFit:false, theme:false},
                  draggable:false,
               collapsible: false,
               showTitle: false,
               showBottom:false,
               dataModel: dataModel,
                colModel: colModel,
                numberCell: { show: false },
                selectionModel: { type: 'none', subtype:'incr', cbHeader:true, cbAll:false}, 
               
                       
                        editable: false,
                        scrollModel: { horizontal: false },
                        showTitle: false,
                        columnBorders: true
                    };
         var $grid = $("#grid_json").pqGrid(obj);
         
         
         
         
         obj.rowSelect = function (evt, ui) {
              console.log(evt);
              if (ui.rowData) {
                 alert("Hiiiii");
                          var $radios = $('input:radio[name=vessel]');
                  $radios.filter('[value=yes]').prop('disabled', true);
                  $radios.filter('[value=no]').prop('disabled', true);
                
                  $('#vslstatus').val("-1");
                 $('#vslstatus').prop("disabled", true);
                 
              }
          };
         
      
         $( "#grid_json").on( "pqgridrowselect", function( event, ui ) {
            alert("vessel selected..");
             
              if (ui.rowData)
              {
                 alert("vessel selected..");
                 var $radios = $('input:radio[name=vessel]');
                  $radios.filter('[value=yes]').prop('disabled', true);
                  $radios.filter('[value=no]').prop('disabled', true);
                
                  $('#vslstatus').val("-1");
                 $('#vslstatus').prop("disabled", true);
             }
         } );

   
      } );      
   

I tried with above two row selector functions but non of them are working. Its not showing the alert messages.

Please someone help me with this issue..


Thanks,    

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: rowSelect is not working..
« Reply #1 on: July 21, 2014, 11:22:46 am »
you need to move your rowSelect callback before initialization of the grid.

          obj.rowSelect = function (evt, ui) {
              console.log(evt);
              if (ui.rowData) {
                  alert("Hiiiii");
                  var $radios = $('input:radio[name=vessel]');
                  $radios.filter('[value=yes]').prop('disabled', true);
                  $radios.filter('[value=no]').prop('disabled', true);                   
                  $('#vslstatus').val("-1");
                  $('#vslstatus').prop("disabled", true);                 
              }
          };

Example:

http://paramquery.com/pro/demos/selection_row