# How to scroll to the highlighed row of the table

**URL:** <https://forum.inductiveautomation.com/t/how-to-scroll-to-the-highlighed-row-of-the-table/54039>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [December 13, 2021, 11:10am UTC](https://forum.inductiveautomation.com/t/how-to-scroll-to-the-highlighed-row-of-the-table/54039 "2021-12-13T11:10:25Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![manjuyadav95.m](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@manjuyadav95.m](https://forum.inductiveautomation.com/u/manjuyadav95.m)\
**Post date:** [December 15, 2021, 2:03pm UTC](https://forum.inductiveautomation.com/t/how-to-scroll-to-the-highlighed-row-of-the-table/54039/21 "2021-12-15T14:03:41Z")

</div>

The steps which i tried was working now after turning off **virtualized rows prop** but it’s focusing frequently even aftr clicking on text field …it is focusing again and again on the same row

“I suggest you pass the params row[‘Id’] and IdTxt to the view and there, on a custom prop expression struct bound to these values, check if they match.  
you might alse have to put a delay in before doing the focus… just to be sure”…  
I am not able to understand this above method.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [December 15, 2021, 2:19pm UTC](https://forum.inductiveautomation.com/t/how-to-scroll-to-the-highlighed-row-of-the-table/54039/22 "2021-12-15T14:19:02Z")

</div>

> [@manjuyadav95.m](#):
>
> it is focusing again and again on the same row

You could send a confirmFocussed message after self.focus() system.perspective.sendMessage("FocusConfirmed")

which the table than listens to and sets a boolean to false

`if not confirmed: system.perspective.sendMessage("RowFocus")`

> [@manjuyadav95.m](#):
>
> I am not able to understand this above method.

Nvm then if the other way works xd

---

<div class="post-metadata">

**Author:** ![manjuyadav95.m](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@manjuyadav95.m](https://forum.inductiveautomation.com/u/manjuyadav95.m)\
**Post date:** [December 15, 2021, 2:45pm UTC](https://forum.inductiveautomation.com/t/how-to-scroll-to-the-highlighed-row-of-the-table/54039/23 "2021-12-15T14:45:56Z")

</div>

I am not getting this one as well…

should I use sendMessage function again on checkbox view script after self.focus() or should I use it in Transform after this line “system.perspective.sendMessage(“RowFocus”)”

and which boolean value to false?

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [December 15, 2021, 3:14pm UTC](https://forum.inductiveautomation.com/t/how-to-scroll-to-the-highlighed-row-of-the-table/54039/24 "2021-12-15T15:14:31Z")

</div>

> [@manjuyadav95.m](#):
>
> should I use sendMessage function again on checkbox view script after self.focus()

yes

> [@manjuyadav95.m](#):
>
> and which boolean value to false?

just a custom property which initial value is set so it will tigger the RowFocus.  
And after receaving the message "FocusConfirmed" on the table it will be set so it nolonger send the message RowFocus

```auto
if not self.props.custom.confirmed: 
  system.perspective.sendMessage("RowFocus")

```

---

<div class="post-metadata">

**Author:** ![manjuyadav95.m](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@manjuyadav95.m](https://forum.inductiveautomation.com/u/manjuyadav95.m)\
**Post date:** [December 16, 2021, 5:48am UTC](https://forum.inductiveautomation.com/t/how-to-scroll-to-the-highlighed-row-of-the-table/54039/25 "2021-12-16T05:48:19Z")

</div>

> [@victordcq](#):
>
> just a custom property which initial value is set so it will tigger the RowFocus.  
> And after receaving the message “FocusConfirmed” on the table it will be set so it nolonger send the message RowFocus

I'm still confused but tried ..not sure correct or not ..

1. I added sendMessage function on checkbox view script  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/4/c4f9a2d6a2f01096908f3911d97ba70f4ebd2b8a.png)
2. The above one getting triggered from Transform code below on main view..

```auto
                        returned_rows.append(row_dict)
			system.perspective.sendMessage("RowFocus")
			self.props.selection.selectedRow=-1

```

1. created custom prop with boolean value and initial value set as true on main view \>root..  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/a/aa1204eabb484a6632b865a1f0442485b8f924ed.png)
2. on main view \> configure script\> created msg handler as per below ..which gets triggered from checkbox view  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/e/bef7ad2633eaf60328070922ea2f799206bc2bd0.png)

the problem is still not solved...scroll is frequently moving up and down

based on a row number, it can be focused on which one is highlighted?

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [December 16, 2021, 7:34am UTC](https://forum.inductiveautomation.com/t/how-to-scroll-to-the-highlighed-row-of-the-table/54039/26 "2021-12-16T07:34:40Z")

</div>

> [@manjuyadav95.m](#):
>
> 1. The above one getting triggered from Transform code below on main view…
> 
> ```auto
> returned_rows.append(row_dict)
> system.perspective.sendMessage("RowFocus")
> self.props.selection.selectedRow=-1
> 
> ```

You gotta put the if here

```auto
returned_rows.append(row_dict)
if not self.(...).custom.Confirmed:
  system.perspective.sendMessage("RowFocus")
self.props.selection.selectedRow=-1

```

> [@manjuyadav95.m](#):
>
> on main view \> configure script\> created msg handler as per below …which gets triggered from checkbox view  
> ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/e/bef7ad2633eaf60328070922ea2f799206bc2bd0.png)

And here you just set it false. dont trigger an other message here  
self.(...).custom.confirmed = false

---

<div class="post-metadata">

**Author:** ![manjuyadav95.m](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@manjuyadav95.m](https://forum.inductiveautomation.com/u/manjuyadav95.m)\
**Post date:** [December 16, 2021, 8:13am UTC](https://forum.inductiveautomation.com/t/how-to-scroll-to-the-highlighed-row-of-the-table/54039/27 "2021-12-16T08:13:52Z")

</div>

Thanks for your reply

I tried it but not successful..I set the below custom prop to false but it was not triggering at all so passed value 0 and it passed the value 0 to custom prop

self.view.getChild("root").custom.Confirmed=0  
and also passed bool(0) to custom prop..neither way worked

in transform below code added

```auto
if self.view.getChild("root").custom.Confirmed==1:
				system.perspective.sendMessage("RowFocus")
			self.props.selection.selectedRow=-1

```

same issue scroll frequently going up n down

And plz check below link ..will this work In my case? if yes then let me know how to do in perspective

> [@Create an auto look up box](https://forum.inductiveautomation.com/t/create-an-auto-look-up-box/939):
>
> I need to create an auto look up box, the process would be as follows, you would type the first letter of a part number in a text box and a row selector would goto the first line in the table that starts with the value typed. Then the process would repeat for each value typed until correct row is found in the table.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [December 16, 2021, 8:17am UTC](https://forum.inductiveautomation.com/t/how-to-scroll-to-the-highlighed-row-of-the-table/54039/28 "2021-12-16T08:17:09Z")

</div>

> [@manjuyadav95.m](#):
>
> but it was not triggering at all

What do you mean? it didnt focus?

---

<div class="post-metadata">

**Author:** ![manjuyadav95.m](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@manjuyadav95.m](https://forum.inductiveautomation.com/u/manjuyadav95.m)\
**Post date:** [December 16, 2021, 8:19am UTC](https://forum.inductiveautomation.com/t/how-to-scroll-to-the-highlighed-row-of-the-table/54039/29 "2021-12-16T08:19:01Z")

</div>

yes its not focused just row got highlighted and I scrolled down and checked for the same…

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [December 16, 2021, 8:20am UTC](https://forum.inductiveautomation.com/t/how-to-scroll-to-the-highlighed-row-of-the-table/54039/30 "2021-12-16T08:20:22Z")

</div>

> [@manjuyadav95.m](#):
>
> And plz check below link …will this work In my case? if yes then let me know how to do in perspective

No this is a topic from 2009 so its vision

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [December 16, 2021, 8:26am UTC](https://forum.inductiveautomation.com/t/how-to-scroll-to-the-highlighed-row-of-the-table/54039/31 "2021-12-16T08:26:12Z")

</div>

> [@manjuyadav95.m](#):
>
> yes its not focused just row got highlighted and I scrolled down and checked for the same…

Thats good we are on the right track! make sure this happens again.

now the problem with the srolling is that you let it trigger on every row. so you will have to put an if in there again.

```auto
if self.view.params.row= payload['row']]:
  self.focus()

```

and add the viewparam row on the checkbox view( this one automatically gets filled in by the table)

and change the message send to include the payload  
`system.perspective.sendMessage("RowFocus", payload={row:row['Id']})`

---

<div class="post-metadata">

**Author:** ![manjuyadav95.m](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@manjuyadav95.m](https://forum.inductiveautomation.com/u/manjuyadav95.m)\
**Post date:** [December 16, 2021, 9:15am UTC](https://forum.inductiveautomation.com/t/how-to-scroll-to-the-highlighed-row-of-the-table/54039/32 "2021-12-16T09:15:04Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/c/3cd0c1b3a2b3cc1c282d12b3ef3e9deec1e257a7.png)  
see above img…the custom prop value not changed to false …after entering text field …the row got highlighted but not focused…

created row param in checkbox view as below…  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/9/59056856eab4f68f65317a79854428881a2faf0c.png)

and on checkbox view \> message handler \>below code written…  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/c/0c593deb711da1ba32ef1639de1cf12f71c3e49d.png)

and this code written on main view table scrip\> msg handler to pass the boolean value as false to custom prop of main view which is named as confirmed…  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/b/3b71d3783062a2307cb3fde30b166d0f02c271b4.png)

and on table data\>transform\> below code written

```auto
returned_rows.append(row_dict)
			if not self.view.custom.confirmed:
				system.perspective.sendMessage("RowFocus", payload={row:row['Id']})
			self.props.selection.selectedRow=-1

```

I am getting this below error after trying the above steps …

```auto
line 4, in onMessageReceived
KeyError: row

```

---

<div class="post-metadata">

**Author:** ![manjuyadav95.m](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@manjuyadav95.m](https://forum.inductiveautomation.com/u/manjuyadav95.m)\
**Post date:** [December 16, 2021, 9:22am UTC](https://forum.inductiveautomation.com/t/how-to-scroll-to-the-highlighed-row-of-the-table/54039/33 "2021-12-16T09:22:57Z")

</div>

Also, I would like to share that by following below steps, It’s triggering only one time focus and then custom property becomes false and if I manually ticked it to true then only it is focusing again and then again becoming false and focus stopped…this actually working but I can’t manually tick the custom property to focus again n again so I made it true on text field onKeyPress event …now its triggering it true and after entering it focusing once and again set false …cycle continues…

steps:

1. payload removed from checkbox script as well as from transform which initially suggested by you…
2. on main view \> table \>msg handler\>focusConfirmed\>written below code…

```auto
self.view.custom.confirmed=bool(0)
self.view.custom.confirmed="false"

```

1. then on table transform below code…

```auto
returned_rows.append(row_dict)
			if self.view.custom.confirmed==bool(1) or self.view.custom.confirmed=="true":
				system.perspective.sendMessage("RowFocus")

```

it’s working as expectednow …  
Let me test it multiple times and will confirm you  
Thanks a lot

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [December 16, 2021, 9:23am UTC](https://forum.inductiveautomation.com/t/how-to-scroll-to-the-highlighed-row-of-the-table/54039/34 "2021-12-16T09:23:20Z")

</div>

ups yea it should be a string, also i guess row[‘id’] doesnt match the data index mb.  
try `len(returned_rows)-1` instead i guess  
`system.perspective.sendMessage("RowFocus", payload={"row":(len(returned_rows)-1)})`

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [December 16, 2021, 9:24am UTC](https://forum.inductiveautomation.com/t/how-to-scroll-to-the-highlighed-row-of-the-table/54039/35 "2021-12-16T09:24:58Z")

</div>

> [@manjuyadav95.m](#):
>
> now its triggering it true and after entering it focusing once and again set false …cycle continues…

Thats fine right?

---

<div class="post-metadata">

**Author:** ![manjuyadav95.m](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@manjuyadav95.m](https://forum.inductiveautomation.com/u/manjuyadav95.m)\
**Post date:** [December 16, 2021, 9:52am UTC](https://forum.inductiveautomation.com/t/how-to-scroll-to-the-highlighed-row-of-the-table/54039/36 "2021-12-16T09:52:46Z")

</div>

No …only the last rows are getting searched/focused properly …starting rows or not … the scroller is moving slowly up after pressing enter on the text field multiple times…

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [December 16, 2021, 9:59am UTC](https://forum.inductiveautomation.com/t/how-to-scroll-to-the-highlighed-row-of-the-table/54039/37 "2021-12-16T09:59:32Z")

</div>

could you get a video of whats happening?

---

<div class="post-metadata">

**Author:** ![manjuyadav95.m](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@manjuyadav95.m](https://forum.inductiveautomation.com/u/manjuyadav95.m)\
**Post date:** [December 16, 2021, 10:09am UTC](https://forum.inductiveautomation.com/t/how-to-scroll-to-the-highlighed-row-of-the-table/54039/38 "2021-12-16T10:09:45Z")

</div>

> [@victordcq](#):
>
> system.perspective.sendMessage("RowFocus", payload={"row":(len(returned\_rows)-1)})

now it's working properly after trying out this below one .. 😍 😍 😍 😍 Thanks a lot

> [@victordcq](#):
>
> system.perspective.sendMessage("RowFocus", payload={"row":(len(returned\_rows)-1)})

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [December 16, 2021, 10:13am UTC](https://forum.inductiveautomation.com/t/how-to-scroll-to-the-highlighed-row-of-the-table/54039/39 "2021-12-16T10:13:45Z")

</div>

phew 😃 i bit complicated to make it work without js but glad it works afterall hehe

---

<div class="post-metadata">

**Author:** ![manjuyadav95.m](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@manjuyadav95.m](https://forum.inductiveautomation.com/u/manjuyadav95.m)\
**Post date:** [December 16, 2021, 11:05am UTC](https://forum.inductiveautomation.com/t/how-to-scroll-to-the-highlighed-row-of-the-table/54039/40 "2021-12-16T11:05:14Z")

</div>

Yoo …thanks a lot 🙂 🙂 🙂👍 😍

[Previous page](https://forum.inductiveautomation.com/t/how-to-scroll-to-the-highlighed-row-of-the-table/54039.md?page=1)

[Next page](https://forum.inductiveautomation.com/t/how-to-scroll-to-the-highlighed-row-of-the-table/54039.md?page=3)
