I am building an application that maintains survey questions. Some questions have a list of canned responses eg Animal or Vegetable or Mineral.
I jumped on Orderlist and I am able to add new items to the list of possible responses (separate button), move them as required to get the order I require.
However, I want to have a Delete button that removes the currently selected item.
How can I find which is the currently selected item so I can remove it from the array?
Thanks
Ross
(long time Primefaces user)
Orderlist needs one more feature
Figured out a way to make it work:
and the action handler for the delete button refers to this.orderList.state.selection :
Code: Select all
<OrderList value={this.state.selectedQ1.options}
ref={(OrderList) => { this.orderList = OrderList; }}
</OrderList>
Code: Select all
deleteOption(e) {
let newOptions = this.state.selectedQ1.options;
let deleteIndex = newOptions.findIndex((d)=> d == this.orderList.state.selection);
console.log(deleteIndex,newOptions[deleteIndex] );
newOptions.splice(deleteIndex,1);
this.updateProperty('options', newOptions);
}
-
- Information
-
Who is online
Users browsing this forum: No registered users and 15 guests