Get Row index from a Dynamic Table | Community
Skip to main content
Level 2
June 17, 2013
Solved

Get Row index from a Dynamic Table

  • June 17, 2013
  • 2 replies
  • 6223 views

Hello Gurus,

How can I get the index of a row when it is added dynamically.

When user clicks on the "-" button he should get the index of the row on which he has clicked the button.

I have tried it using the code

var var1 = (data.Design_page1.Working_times_subform.Working_Table.Row1.instanceManager.count-1);

But it gives me the total row count.I want the index of the particular row.

Thanks.

Regards,

Nikhil

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Jono_Moore

On the "-" button use this.parent.parent.index to get the index of the row the button is in. the "parent" reference is used to move back up the hierarchy so if you had say a subform around the button in the cell you'd have to add another parent to find Row1.

So to delete the row try: _Row1.removeInstance(this.parent.parent.index);

Or this should work too: _Row1.removeInstance(Row1.index);

The underscore is a shortcut to the Instance Manager. You may want to avoid using it in object names, I'm pretty sure it's caused me problems in the past, I only use camel case for object names now (avoid dashes too).

You don't need to specify the entire path to the object you're trying to access. The "-" button being below Row1 can see Row1.

2 replies

Jono_Moore
Jono_MooreAccepted solution
Level 10
June 17, 2013

On the "-" button use this.parent.parent.index to get the index of the row the button is in. the "parent" reference is used to move back up the hierarchy so if you had say a subform around the button in the cell you'd have to add another parent to find Row1.

So to delete the row try: _Row1.removeInstance(this.parent.parent.index);

Or this should work too: _Row1.removeInstance(Row1.index);

The underscore is a shortcut to the Instance Manager. You may want to avoid using it in object names, I'm pretty sure it's caused me problems in the past, I only use camel case for object names now (avoid dashes too).

You don't need to specify the entire path to the object you're trying to access. The "-" button being below Row1 can see Row1.

Level 2
June 18, 2013

Hi Jono,

Thanks for the help.This is excatly what I was searching for.

Also thanks for the insighful suggestions.I wil suerly try and avoid using underscores and dashes.

Thanks.

Regards,

Nikhil