Author Topic: How to trigger a function onchnage dropdown list item in paramquery?  (Read 3696 times)

EPM Solutions

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 182
    • View Profile
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]
                   }

      },

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: How to trigger a function onchnage dropdown list item in paramquery?
« Reply #1 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());
});
},

EPM Solutions

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 182
    • View Profile
Re: How to trigger a function onchnage dropdown list item in paramquery?
« Reply #2 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;
                                }
                     });                  
                     }
                 }
              ]

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: How to trigger a function onchnage dropdown list item in paramquery?
« Reply #3 on: September 21, 2017, 10:00:32 am »
Have you tried updateRow method to update the values in the same row?

EPM Solutions

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 182
    • View Profile
Re: How to trigger a function onchnage dropdown list item in paramquery?
« Reply #4 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