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.
Hi Aman
Try changing the condition in ListIndexOf like this
Also, I would recommend deleting elements directly using the Current property of the list.
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
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.
Anshul
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
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
Hi Aman Devrath,
please change
the correct one is...
"Enter" button on the keyboard, please use the OnKeypress event.
Hi Ramesh, thanks for the help.
It worked. For the onkeypress event, I have to use javascript right? like like this answer ?
yes, correct. please use javascript. I hope no use for "Add" button. please use javascript for input box ON CHANGE.