Author Topic: pqGrid events only containing little information  (Read 3235 times)

heinenf

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 10
    • View Profile
pqGrid events only containing little information
« on: February 22, 2019, 08:23:22 am »
Hello,

in the event beforeRowSelect we want to return false when the user clicks on the triangle that opens childelements when the grid is in treemode. However, it seems that we can't get the keyCode events from eventtype pwGrid:beforeRowSelect because all the properties are undefined. It seems that most of the events don't carry these information.

The only way we can think of is to check the code like this: if(event.keyCode ===13) is to use window.event instead of the provided event.

However our client uses Firefox 52 and it does not support window.event...

Any suggestions? (We use pqGrid Version 5.2)

regards,

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: pqGrid events only containing little information
« Reply #1 on: February 22, 2019, 04:49:37 pm »
event.keyCode makes sense in case of keyboard events.
I'm not sure why would you check event.keyCode upon click on the triangle to expand tree.

beforeTreeExpand and beforeCellClick, cellClick are the appropriate events in case of click.

Can you please mention what exactly are you trying to do. And by treemode you mean treegrid? https://paramquery.com/pro/demos52/treegrid

heinenf

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: pqGrid events only containing little information
« Reply #2 on: February 26, 2019, 09:16:30 am »
Yes sorry I will explain it more clearly.

What we want to achieve is that if the user clicks on the triangle in treegrid the tree will get expanded but it will not select the row. Only expand the tree.

Currently the behavior does both. Expanding the tree and also selecting the row. So in order to make it only expand the tree we want to check that the triangle was clicked and then in beforeRowSelect event we will return false to supress the rowSelect.

To achieve this we want to check the event. That's the code:

beforeRowSelect: function(event, ui) {
let evt = window.event || event;
       if($(evt.target).hasClass("ui-icon-triangle-1-se") || $(evt.target).hasClass("ui-icon-triangle-1-e")) {
          return false;
      }
}

Now the problem is that evt.target is not available when using the provided event. We have to use window.event for this but window.event is not available in our clients browser


paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: pqGrid events only containing little information
« Reply #3 on: February 26, 2019, 06:31:30 pm »
Ok I guess you are using pure row selections without checkboxes.

Code: [Select]
selectionModel: { type: 'row' }

Please try either of the below solutions.

Code: [Select]
beforeCellClick: function(evt, ui){

var target = evt.originalEvent.target;
if($(target).hasClass("pq-group-icon") ) {
                        this.Tree()[ui.rowData.pq_close? 'expandNodes': 'collapseNodes']([ui.rowData])
          return false;
      }
},

or

Code: [Select]
beforeCellClick: function(evt, ui){

var target = evt.originalEvent.target;
if( $(target).hasClass("pq-group-icon") ) {
this.one('beforeRowSelect', function(){
return false;
});
}
},
« Last Edit: February 26, 2019, 07:44:53 pm by paramquery »

heinenf

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: pqGrid events only containing little information
« Reply #4 on: March 01, 2019, 12:00:45 pm »
The second solution led to the strange behavior of multiple selected rows but the first one worked perfectly. Thank you