ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: EPM Solutions on September 20, 2017, 11:37:51 am

Title: How to trigger a function onchnage dropdown list item in paramquery?
Post by: EPM Solutions on September 20, 2017, 11:37:51 am
Hi team,

I want to trigger a function onchange dropdown list. I am using below code from the paramquery site which is not working for us. I want to call function1 on selecting Action1 option and function2 on selecting Action2 from the below code. How to achieve this.? Please response asap.

{ title: "Action", width: 150, dataType: "string",
                   editor: {
                       type: 'select',
                       options: ['--None--', 'Action1', 'Action2'],
                       getData:function(ui){
                          ui.$cell.find("select").val();
                          console.log(ui.$cell.find("select").val())
                       }
                   }

      },

---------------------

I have used listeners also as below, but not working.

function action_handler() {
alert('Success');
}

{ title: "Action", width: 150, dataType: "string",
                   editor: {
                       type: 'select',
                       options: ['--None--', 'Action1', 'Action2'],
                       listeners: ['change', action_handler]
                   }

      },
Title: Re: How to trigger a function onchnage dropdown list item in paramquery?
Post by: paramvir on September 20, 2017, 02:37:25 pm
Any event to editor can be bind in editor.init callback.

Code: [Select]
init: function(ui){
ui.$editor.on('change', function(){
alert($(this).val());
});
},
Title: Re: How to trigger a function onchnage dropdown list item in paramquery?
Post by: EPM Solutions on September 20, 2017, 03:52:38 pm
Thanks team,

this is working as expected. How can I change the colModel title based on condition from below code?

obj.colModel =   [{ title: "Status", width: 150, dataType: "string", dataIndx: "Status"},
                         { title: "Action", width: 150, dataType: "string",

                   editor: {
                       type: 'select',
                       options: ['--None--', 'In', 'Out'],
                       init: function(ui){
                           ui.$editor.on('change', function(){
                      if ($(this).val() == "In") {
                                     // I want to set Status as active for this particular row;
                                } else if($(this).val() == "Out") {
                                         // I want to set Status as Inactive for this particular row;
                                }
                     });                  
                     }
                 }
              ]
Title: Re: How to trigger a function onchnage dropdown list item in paramquery?
Post by: paramvir on September 21, 2017, 10:00:32 am
Have you tried updateRow method to update the values in the same row?
Title: Re: How to trigger a function onchnage dropdown list item in paramquery?
Post by: EPM Solutions on September 21, 2017, 11:42:03 am
I have got it solved using getRowData method as below,

var column = $( ".selector" ).pqGrid("getRowData", {rowIndx: rowIndx} );
column.Status = "Active";
$( ".selector" ).pqGrid("refresh");

Thanks