[broken in 8.6] JS To Select First Row

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

[broken in 8.6] JS To Select First Row

Post by PointsWell »

The Problem:
I have multiple levels of Master Detail grids

Parent drives Child drives Details
The Child grid has a default action which populates the Details grid. The Child grid refreshes when a record on the Parent is selected (via a process which updates an ID field on LIRU).

The challenge is that when the Child grid refreshes the Select first row option is then ignored, which results in the no record being selected which prevents the default action on the Child grid refreshing the Details grid.

The question
Is there JS that I can add to force the selection of the first record in the Child grid?
Last edited by PointsWell on Sat Jun 19, 2021 2:07 pm, edited 4 times in total.
johntalbott
Posts: 619
Joined: Wed Jun 17, 2015 11:16 pm
Location: Omaha, Nebraska
Contact:

Re: JS To Select First Row

Post by johntalbott »

In the dataBound event of the Child grid you can do this.

In Render Script of child grid

Code: Select all

widget.bind("dataBound", function(e){
      const grid = e.sender
     grid.select("tr:eq(0)");
})
VocalDay Solutions - Agility - Predictability - Quality

We specialize in enabling business through the innovative use of technology.

AwareIM app with beautiful UI/UX - https://screencast-o-matic.com/watch/crfUrrVeB3t
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: JS To Select First Row

Post by PointsWell »

johntalbott wrote:In the dataBound event of the Child grid you can do this.

In Render Script of child grid

Code: Select all

widget.bind("dataBound", function(e){
      const grid = e.sender
     grid.select("tr:eq(0)");
})
Thanks, that keeps it highlighted but it isn't triggering the default operation to make the details grid update.
johntalbott
Posts: 619
Joined: Wed Jun 17, 2015 11:16 pm
Location: Omaha, Nebraska
Contact:

Re: JS To Select First Row

Post by johntalbott »

Code: Select all

widget.bind("dataBound", function(e){
      const grid = e.sender;
     grid.select("tr:eq(0)");
     grid.select().click();
})
VocalDay Solutions - Agility - Predictability - Quality

We specialize in enabling business through the innovative use of technology.

AwareIM app with beautiful UI/UX - https://screencast-o-matic.com/watch/crfUrrVeB3t
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: JS To Select First Row

Post by PointsWell »

Perfect! Thank you very much John.
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: JS To Select First Row

Post by PointsWell »

PointsWell wrote:Perfect! Thank you very much John.
So, I was a little previous on my perfect...

2 follow up questions:

1 - The JS route doesn't play nicely with a grid that has a grouping on it, it appears to be selecting the unformatted query row, you can see the highlighted row between the row of data and the row acting as the grouping.
Screen Shot 2020-05-04 at 10.35.10.png
Screen Shot 2020-05-04 at 10.35.10.png (6.96 KiB) Viewed 11449 times
2 - Is there a way to trigger another process if there is no records returned as the target panel is a receiver rather than a listener so doesn't know the state of the query only what it is told - eg display this record, but if there is no record it doesn't get the trigger to refresh.
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

The Conditions

Post by PointsWell »

If you use the render script and have a default operation on record which starts a process (as opposed to a simple View Object) you will create an infinite loop.

It appears that the Start Process causes the grid to refresh which then triggers the render script, which starts the process, which triggers the render script... you see where this is going.
johntalbott
Posts: 619
Joined: Wed Jun 17, 2015 11:16 pm
Location: Omaha, Nebraska
Contact:

Re: [Solved-with Conditions] JS To Select First Row

Post by johntalbott »

Some clarification on the code ...

The render script runs once when the grid is initially rendered. It won't run again unless the container of the grid is refreshed. e.g. refreshing your browser.

Having said that, when the render script runs the single time, the JS code "sets up" an event handler for the dataBound event of the grid that fires every time data is loaded into the grid even if that's zero records.

One way or another, what you want can be accomplished. It will take being able to see your specific configuration and use case.
VocalDay Solutions - Agility - Predictability - Quality

We specialize in enabling business through the innovative use of technology.

AwareIM app with beautiful UI/UX - https://screencast-o-matic.com/watch/crfUrrVeB3t
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: [Solved-with Conditions] JS To Select First Row

Post by Jaymer »

John
per this thread,
this doesn't seem to work in 8.6 any longer.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: [Solved-with Conditions] JS To Select First Row

Post by PointsWell »

Can confirm that this no longer works with v8.6 where was working previously.
Post Reply