Force selection of first record on query result.

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
KnightWare
Posts: 139
Joined: Sat Feb 10, 2018 12:56 am

Force selection of first record on query result.

Post by KnightWare »

The the "Select First Record" is checked on a query, and works when the query initiates and runs on a presentation panel. However further Auto-refreshes (such as Process run, or other BO changed) refreshes the query but does NOT select the first record. Anyway to force this?
Last edited by KnightWare on Wed Jun 02, 2021 9:50 pm, edited 2 times in total.
KnightWare
Posts: 139
Joined: Sat Feb 10, 2018 12:56 am

Re: Force selection of first record on query result.

Post by KnightWare »

Looks interesting, but not for me it's not a child/parent relationship. When I added that JS to the render script of the query, the Auto Refresh stopped working.

I have query results (grid) on one panel of my presentation. As described in your link, first record highlight's and selects when first presented. However when another BO on another panel is modified, the query is set to auto refresh, which it does. Just the first record does not highlight and get selected. I need the selection to trigger after the refresh, so a process runs to to set the other objects in the presentation.

I figured I need to instantiate the grid object as your javascript does, but not familiar with the syntax.
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: Force selection of first record on query result.

Post by PointsWell »

The linked solution works in the way you are asking, an update elsewhere triggering a refresh in the target grid and the target grid not doing the select first record.
KnightWare
Posts: 139
Joined: Sat Feb 10, 2018 12:56 am

Re: Force selection of first record on query result.

Post by KnightWare »

I placed the code as is in the Render Script of the Query. When I did, the Query did NOT refresh when the other BO was saved. ,
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: Force selection of first record on query result.

Post by PointsWell »

KnightWare wrote: Thu Jun 03, 2021 12:07 am I placed the code as is in the Render Script of the Query. When I did, the Query did NOT refresh when the other BO was saved. ,
Hmm that worked in, I think, v8.4, I wonder if the Kendo update affected this.
johntalbott
Posts: 619
Joined: Wed Jun 17, 2015 11:16 pm
Location: Omaha, Nebraska
Contact:

Re: Force selection of first record on query result.

Post by johntalbott »

Are there errors in the browser console?

A quick screencast demonstrating the problem would help a lot.
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
KnightWare
Posts: 139
Joined: Sat Feb 10, 2018 12:56 am

Re: Force selection of first record on query result.

Post by KnightWare »

No errors reported in Console. Having this code in the render script of the Query defiantly stops the auto refresh.

widget.bind("dataBound", function(e){
const grid = e.sender;
grid.select("tr:eq(0)");
grid.select().click();
})

Remove it and the grid refreshes , but first row not selected.
Screencast?
KnightWare
Posts: 139
Joined: Sat Feb 10, 2018 12:56 am

Re: Force selection of first record on query result.

Post by KnightWare »

johntalbott - sent you PM
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Force selection of first record on query result.

Post by Jaymer »

KnightWare wrote: Thu Jun 03, 2021 1:49 am No errors reported in Console. Having this code in the render script of the Query defiantly stops the auto refresh.
yes, i agree

added this code, and even clicking the refresh icon would NOT redraw the grid. A process had added a record and it would not show up. Before adding this code, the built-in aware refresh mechanism was updating the grid after my process added a record.
I'm trying to get that new, top-most record selected, so it will fire the default Row Operation.

Had to refresh (re-login) the entire app to make that panel redraw to show the new record.
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
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Force selection of first record on query result.

Post by Jaymer »

this is a visual example of whats happening from the original post:

1st pic shows parent-child grids.
top one has 'select first record'
default actions runs process, saves an ID, DISPLAYs the child query

another panel (not shown) has a button to add a new transaction, via process.
2nd picture shows AFTER the top grid auto refreshed based on that process running. this is correct behavior.

NOTE how the "first record" DID NOT get selected on the refresh, leaving the user to manually click on the new record to show the correct child.
The selected record (in brown) stayed selected, and moved from top to the 2nd spot as the new one came to the top.
Last edited by Jaymer on Wed Jun 16, 2021 9:02 pm, edited 1 time in total.
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
johntalbott
Posts: 619
Joined: Wed Jun 17, 2015 11:16 pm
Location: Omaha, Nebraska
Contact:

Re: Force selection of first record on query result.

Post by johntalbott »

Try this ...

Code: Select all

widget.bind("dataBound", function (e) {
    const grid = e.sender;
    const row = grid.table.find("tr:eq(0)");
    
    parser.highlightRow(row, grid); // This is what highlights (selects) the row.
    grid.select().click();  // This is only needed to run the default row operation.
})
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
KnightWare
Posts: 139
Joined: Sat Feb 10, 2018 12:56 am

Re: Force selection of first record on query result.

Post by KnightWare »

JohnTalbott - That put it in an endless loop. Placing it in the render script of the query. Need to dig in because that doesn't make sense to me.
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Force selection of first record on query result.

Post by Jaymer »

I agree - endless loop - no good
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
johntalbott
Posts: 619
Joined: Wed Jun 17, 2015 11:16 pm
Location: Omaha, Nebraska
Contact:

Re: Force selection of first record on query result.

Post by johntalbott »

It works for me. Show me the endless loop.
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
Post Reply