Can I have the top row in query selected if only 1 match?

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
BLOMASKY
Posts: 1470
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

Can I have the top row in query selected if only 1 match?

Post by BLOMASKY »

I have a query with filters. I would like, if the customers filters only found 1 match to have the row selected. But if more than one match, to NOT have it selected. Is this possible. (The reason why, is that this is on a VP with a few other related queries and it takes about 2 seconds for all of them to be populated. I do not want to have the original query delayed by the 2 seconds.

Bruce
johntalbott
Posts: 619
Joined: Wed Jun 17, 2015 11:16 pm
Location: Omaha, Nebraska
Contact:

Re: Can I have the top row in query selected if only 1 match

Post by johntalbott »

Try this ...

Query Render Script

Code: Select all

widget.bind("dataBound", function(e) {
    if (widget.items().length === 1) {
         widget.select("tr:eq(0)");
     })
}
Last edited by johntalbott on Tue Jan 14, 2020 12:28 am, edited 1 time in total.
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
BLOMASKY
Posts: 1470
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

Good news, bad news John

Post by BLOMASKY »

The good news, it DOES select it (after I add a ")" to the end that was missing.

The bad news is that Aware doesn't know it so it does NOT trigger the default event when clicking on the row.

Bruce
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: Can I have the top row in query selected if only 1 match

Post by PointsWell »

The clunky way to do it is to have two different but almost identical queries and call them from a process.

If the find count is =1 then show the query that has the first row select, if the count>1 then show the query that does not have any rows selected.

Downside is that there are redundant queries that require additional maintenance.
johntalbott
Posts: 619
Joined: Wed Jun 17, 2015 11:16 pm
Location: Omaha, Nebraska
Contact:

Re: Can I have the top row in query selected if only 1 match

Post by johntalbott »

Are you saying that even when you physically click the row it doesn't work?
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
johntalbott
Posts: 619
Joined: Wed Jun 17, 2015 11:16 pm
Location: Omaha, Nebraska
Contact:

Re: Can I have the top row in query selected if only 1 match

Post by johntalbott »

This should do the trick ...

Query Render Script

Code: Select all

widget.bind("dataBound", function (e) {
	if (widget.items().length === 1) {
		widget.select("tr:eq(0)")
		parser.onTableClick("tr:eq(0)", widget)
	}
})
With this approach, you might not need this line:

Code: Select all

widget.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
BLOMASKY
Posts: 1470
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

You are a (smart) gentleman and scholar

Post by BLOMASKY »

This works just fine.

Thanks
Bruce
Post Reply