Author Topic: Need to double click on a drop down to select a value  (Read 4352 times)

applepqgrid

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 26
    • View Profile
Need to double click on a drop down to select a value
« on: July 13, 2018, 03:50:25 am »
Hi PQGrid Team,

We have a pro account and we are stuck with below issue.

Issue Description:

We are using PQGrid library to create a data grid which has a drop down inside a cell. We want that on single click the drop down in the grid cell should be editable but drop down is opening on second click. How to avoid multiple clicks to open drop down in edit mode?
We tried below options but none of them worked. Please suggest some option as this is important for our application to have single click dropdown edit.

1. We used the PQGrid clickToEdit property and assigned 1 as value.

2. We also tried fixing with jQuery by binding click event on parent element like below:
$('.superparentclass').on('click','selectdropdowncontainerclass',function() {
$('.pq-editor-outer').find('select').trigger('click');});

We tried with 'change' and 'open' event too but did not work.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Need to double click on a drop down to select a value
« Reply #1 on: July 13, 2018, 09:44:39 am »
Native browser select list can't be created and opened in a single click because there is no known way to programmatically open it.

It requires use of pqSelect component as editor to do so.

Please include pqSelect files in the document and add this code in column.editor.init callback.

Code: [Select]
      init: function (ui) {
        ui.$cell.find("select").pqSelect(); //first create it.
setTimeout(function(){
ui.$cell.find("select").pqSelect('open');// programmatically open the editor.
})
      },

And yes it also requires editModel.clicksToEdit: 1
Code: [Select]
editModel: {
    clicksToEdit:1,
    ... 
}
« Last Edit: July 13, 2018, 09:57:14 am by paramquery »

applepqgrid

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Need to double click on a drop down to select a value
« Reply #2 on: July 21, 2018, 02:18:01 am »
Thanks for the reply.

I have tried the approach you have suggested by making the changes. The following function is not triggering:
 column.editor.init = function (ui) {
        ui.$cell.find("select").pqSelect();
   setTimeout(function(){
      ui.$cell.find("select").pqSelect('open');
   })                  
 }

The init function is not working. Can you suggest other approach for resolving the issue?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Need to double click on a drop down to select a value
« Reply #3 on: July 23, 2018, 11:55:56 am »
editor.init is not triggering implies it's not implemented correctly.

Do you see any error in the browser developer console and how have you taken reference to the column.

editor.init callback is usually defined inline during initialization as in this example.

https://paramquery.com/pro/demos/editing_custom

"Shipping Via" column.

applepqgrid

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Need to double click on a drop down to select a value
« Reply #4 on: August 07, 2018, 08:20:53 am »


We are able to integrate and the drop down is populating in single click. But while when we try to click on already selected option, nothing is happening even though the selection is preserved.This may cause confusion to the user since the drop down popup is not disappearing.

Please suggest me how I can fix the above problem.

Note : I can reproduce the same behavior in the demo link shared.

« Last Edit: August 07, 2018, 09:50:21 am by applepqgrid »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Need to double click on a drop down to select a value
« Reply #5 on: August 07, 2018, 08:53:17 pm »
this is the default behaviour and I'm afraid I don't see any option to configure that.

Normally user opens the select list to select other option but not the same one.

And popup is closed with click outside the popup or when escape key is pressed.