Profound UI Grid-get grid row number on grid double click in javascript

Use this board to ask questions or have discussions with other Genie users.
Post Reply
SrinivasSiripuram
New User
Posts: 14
Joined: Wed Feb 26, 2020 4:24 pm
First Name: Srinivas
Last Name: Siripuram
Company Name: UPMC
Phone: 2015655901
Address 1: 532 Chatham Park Dr, APT 2A
Address 2: Pittsburgh
City: Pittsburgh
State / Province: Pennsylvania
Zip / Postal Code: 15220
Country: United States
Contact:

Profound UI Grid-get grid row number on grid double click in javascript

Post by SrinivasSiripuram »

Hi,

In JavaScript, I am trying to get selected row number in the Profound Grid when double clicking on the grid row.

Can you please some one help, how to achieve this.

In the Genie designer its automatically giving row number, but i need the selected row number in JavaScript, when grid double click event fired.

Please suggest.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Profound UI Grid-get grid row number on grid double click in javascript

Post by Scott Klement »

I'm not sure that I understand. Could you provide an example that I could try on my own machine to understand better?
SrinivasSiripuram
New User
Posts: 14
Joined: Wed Feb 26, 2020 4:24 pm
First Name: Srinivas
Last Name: Siripuram
Company Name: UPMC
Phone: 2015655901
Address 1: 532 Chatham Park Dr, APT 2A
Address 2: Pittsburgh
City: Pittsburgh
State / Province: Pennsylvania
Zip / Postal Code: 15220
Country: United States
Contact:

Re: Profound UI Grid-get grid row number on grid double click in javascript

Post by SrinivasSiripuram »

Hi Scott,
As shown attached screen shot, In Genie designer in onrowdblclick event, I am getting the row number which I have clicked in the grid, so that I am able to get the cell value by using row number.


I am trying to write the onrowdblclick event in javascript, but not finding the way to get the row number dynamically when I clicked on the grid row.

getObj("myGrid").grid.onrowdblclick = function handleRowClick(row, isRightClick)
{
if (!isRightClick) {
var value = getObj("subfile").grid.getCellValue(row, 0);
console.log(Value);
//All customized code goes here

}

I have to pass the row number which I have clicked in the grid. Is there any way to find out the grid row number which is clicked.
Can you please suggest how to get the row number in JavaScript.
Attachments
Grid1.PNG
Grid1.PNG (71.14 KiB) Viewed 4839 times
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Profound UI Grid-get grid row number on grid double click in javascript

Post by Scott Klement »

You posted the following code that doesn't make sense to me:

Code: Select all

getObj("myGrid").grid.onrowdblclick = function handleRowClick(row, isRightClick)
{
   if (!isRightClick) {
      var value = getObj("subfile").grid.getCellValue(row, 0);
      console.log(Value);
      
//All customized code goes here

}
This seems nonsensical. You can't just attach an "onrowdblclick" field onto the grid object and expect the code in the grid to run it when you want it to. Can you explain why you are doing this?
SrinivasSiripuram
New User
Posts: 14
Joined: Wed Feb 26, 2020 4:24 pm
First Name: Srinivas
Last Name: Siripuram
Company Name: UPMC
Phone: 2015655901
Address 1: 532 Chatham Park Dr, APT 2A
Address 2: Pittsburgh
City: Pittsburgh
State / Province: Pennsylvania
Zip / Postal Code: 15220
Country: United States
Contact:

Re: Profound UI Grid-get grid row number on grid double click in javascript

Post by SrinivasSiripuram »

Hi Scott,

I am sorry, if i am not clear, i am trying to write grid row click functionaliy in javascript, for that i need, grid row number which is clicked
by the user.

In the below sample code i am passing the grid row number as 2 (hard coding the row number). Which is working fine when i click on the grid row, but i am
trying to get the grid row number which is clicked dynamically. Is there any way to get the row number in JavaScript. Please suggest.

getObj('subfile').addEventListener('click', function(){

var rowOffset = 5;

var screenRow = 2 + rowOffset;

console.log(2);

changeElementValue('I_' + screenRow + '_13','1');

environment = getObj("subfile").grid.getCellValue(2, 1);

envDesc = getObj("subfile").grid.getCellValue(2, 2);

pui.setCookie("ENV",environment);

pui.setCookie("ENVDESC", envDesc);


});
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Profound UI Grid-get grid row number on grid double click in javascript

Post by Scott Klement »

In your screenshot where you coded the 'onrowdblclick' property of the grid widget, you are doing this the correct way.

Can you explain why that method doesn't work for you?
SrinivasSiripuram
New User
Posts: 14
Joined: Wed Feb 26, 2020 4:24 pm
First Name: Srinivas
Last Name: Siripuram
Company Name: UPMC
Phone: 2015655901
Address 1: 532 Chatham Park Dr, APT 2A
Address 2: Pittsburgh
City: Pittsburgh
State / Province: Pennsylvania
Zip / Postal Code: 15220
Country: United States
Contact:

Re: Profound UI Grid-get grid row number on grid double click in javascript

Post by SrinivasSiripuram »

Hi Scott,

The way which i mentioned in the screen shot is working perfectly fine. That is from Genie designer, which is specific to one grid.

But we have more than 500 grids, for each grid we have to go and write the onrowdblclick code which is time taking, so we are looking the way
we can write a JavaScript function and we can call it on grid row double click. But here the challenging thing is getting the grid row number in JavaScript when the user clicks on grid row.

Please suggest,if is there any api available to get the grid row number when the user clicks on grid row in JavaScript.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Profound UI Grid-get grid row number on grid double click in javascript

Post by Scott Klement »

What I would do is write a JavaScript function and link it into the Genie skin's start html (by adding a <script> tag to the start.html).

Then, for each screen, all you need to do is change the "onrowdblclick" property so that it calls that function.
PASHAT8046
New User
Posts: 1
Joined: Tue Feb 04, 2020 12:04 pm
First Name: shivateja
Last Name: pasham
Company Name: upmc
Contact:

Re: Profound UI Grid-get grid row number on grid double click in javascript

Post by PASHAT8046 »

So as per understanding, there no possible way to get row number from JavaScript, with click functionality?

Do we need to handle that in Genie designer only? to have access to row number?
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Profound UI Grid-get grid row number on grid double click in javascript

Post by Scott Klement »

PASHAT8046 wrote:So as per understanding, there no possible way to get row number from JavaScript, with click functionality?
No... that's not true. Getting the row number is easy, it is provided to you in a variable named 'row' if you're using the proper events provided by Genie.

However, this is not possible:

Code: Select all

getObj("myGrid").grid.onrowdblclick = function...
the 'grid' object is not a DOM object, so you can't assign an event to it directly like that. Even if you could, 'onrowdblclick' isn't an DOM event, its one created specially as part of the Profound UI product, so you have to use Profound UI's way of doing things, not bypass it and try to use a DOM event.

In this example, he also tried to use a DOM event rather than a Genie one:

Code: Select all

   getObj('subfile').addEventListener('click', function(){
   ...
Similar problem, here... though, 'click' is a valid DOM event, and 'subfile' will be a valid DOM object, so this code will cause a click event to fire, but it won't be row-specific, it will apply to the div element that the entire grid is built inside, and will apply to the whole thing. Also, because it is a DOM event rather than a Profound UI event, we don't have the ability to insert our own code, so we can't set custom values in there for you.

So the problem was never getting the row... the problem was a poor understanding of how grids and Profound UI works.
PASHAT8046 wrote:Do we need to handle that in Genie designer only? to have access to row number?
Its not clear why you'd want to do this. Are you trying to apply this double click to every single grid without ever having to open it up in the Genie designer?

I think that's possible to do, but I've never heard of someone doing it before and I haven't tried it myself.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests