70
Views
8
Comments
Solved
delete button removes the last element in to-do list
Application Type
Reactive

Hello guys,

I'm making a to-do list mobile app. There's a delete button for every element added, but when I click the delete button it deletes the last element added in the last. I'm not sure what went wrong.

Also, is it possible to add element using "Enter" button on the keyboard? I have to first type in the input box and then click the button all the time.


ToDo.oml
2023-04-18 10-31-31
Anshul Jain
Solution

Hi Aman

Try changing the condition in ListIndexOf like this

Also, I would recommend deleting elements directly using the Current property of the list.

2024-04-15 16-08-47
Aman Devrath

Hi Anshul, thanks for the help.

Could you please explain this "Also, I would recommend deleting elements directly using the Current property of the list " ? 

Thanks

Aman

2023-04-18 10-31-31
Anshul Jain

Hi Aman,

What I meant was to use CurrentRowNumber to delete the specific ListItem. Delete the input parameter and the local var in your DeleteElementOnCLick action as they are of no need and then remove the ListIndexOf as well. Simply use ListRemove with CurrentRowNumber like this


This is a better approach in the case when there are more than 1 element in the list with the same attribute text(Value of Element in the list) and you click on the latter one to delete in that case there is a high chance that the element that appears first with the same name will be deleted instead of the one that you clicked, since IndexOf will return the Index of the first occurrence.


Thanks

Anshul

2025-10-18 11-13-53
Ramesh subramanian

Hi Anshul Jain,

 please don't use CurrentRowNumber. because  row number start with 1 to n. 

if you want use 

CurrentRowNumber -1 to remove ListIndex . 

because  Index will start 0 to n.

thanks,

Ramesh

2023-04-18 10-31-31
Anshul Jain

Hi Ramesh,

CurrentRowNumber starts from 0 only as you can see in the description provided in the Service Studio

So no need to use CurrentRowNumber -1 as it might throw out of index exception

Thanks 

Anshul

2025-10-18 11-13-53
Ramesh subramanian
Solution

Hi Aman Devrath,

please change

the correct one is...



"Enter" button on the keyboard, please use the OnKeypress event.



2024-04-15 16-08-47
Aman Devrath

Hi Ramesh, thanks for the help.

It worked. For the onkeypress event, I have to use javascript right? like like this answer ?

Thanks

Aman

2025-10-18 11-13-53
Ramesh subramanian

yes, correct. please use javascript. I hope no use for "Add" button. please use javascript for input box  ON CHANGE. 

2023-04-18 10-31-31
Anshul Jain
Solution

Hi Aman

Try changing the condition in ListIndexOf like this

Also, I would recommend deleting elements directly using the Current property of the list.

2024-04-15 16-08-47
Aman Devrath

Hi Anshul, thanks for the help.

Could you please explain this "Also, I would recommend deleting elements directly using the Current property of the list " ? 

Thanks

Aman

2023-04-18 10-31-31
Anshul Jain

Hi Aman,

What I meant was to use CurrentRowNumber to delete the specific ListItem. Delete the input parameter and the local var in your DeleteElementOnCLick action as they are of no need and then remove the ListIndexOf as well. Simply use ListRemove with CurrentRowNumber like this


This is a better approach in the case when there are more than 1 element in the list with the same attribute text(Value of Element in the list) and you click on the latter one to delete in that case there is a high chance that the element that appears first with the same name will be deleted instead of the one that you clicked, since IndexOf will return the Index of the first occurrence.


Thanks

Anshul

2025-10-18 11-13-53
Ramesh subramanian

Hi Anshul Jain,

 please don't use CurrentRowNumber. because  row number start with 1 to n. 

if you want use 

CurrentRowNumber -1 to remove ListIndex . 

because  Index will start 0 to n.

thanks,

Ramesh

2023-04-18 10-31-31
Anshul Jain

Hi Ramesh,

CurrentRowNumber starts from 0 only as you can see in the description provided in the Service Studio

So no need to use CurrentRowNumber -1 as it might throw out of index exception

Thanks 

Anshul

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.