0

How to delete checked items in listbox with checkmark true

asked 2020-03-17 21:17:43 +0800

jayskak gravatar image jayskak
31

hi guys, i have problem with my project, i just can delete only one selected item in my listbox. And now, i have to add some fiture on my listbox that can delete multiple items. i was found attribute checkmark checkmark="true" multiple="true". but i don't know how use that attribute sync with my controller, how i know the item was checked?

this is my method in controller

 public void deleteDetail() {
        detailList.remove(detail);
        kalkulasiDiskonGlobal();
    }

sorry for my bad english, thanks guys.

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2020-03-19 10:29:15 +0800

MDuchemin gravatar image MDuchemin
2560 1 6
ZK Team

Hi there jayskak,

There are a few options depending on your project's structure and pattern. The recommended way to handle listbox with dynamic content is to use a model object containing the values. It can be a flat List (or other types), but the better option is to use ListModelList You can create a ListModelList from your data in composer and assign it as the model for your component. Then, the selection state is available directly on the ListModel with model.getSelection() Here's a fiddle showing how to use that.

Here's the documentation about listmodel and the one about listbox.

If you are creating the listbox content manually instead of using model, you can use selectedItems or selectedIndex from the listbox directly. This is way less efficient in the long run and might cause issues if you are using these methods with another form of component control such as model, so I would not recommend unless you don't a choice.

link publish delete flag offensive edit
-1

answered 2020-03-19 06:34:59 +0800

MiguelMdz gravatar image MiguelMdz
9 1

updated 2020-03-19 06:41:01 +0800

Hello, use a loop for example:

for(int i=0; i<detailList.size(); i++){
 detailList.remove(i);
 }

or whit variable/ flag.

for(int i=0; i< detailList.size(); i++) {
    if(selectDetail == detailList.get(i)) {
    detailList.remove(i);
    }

}

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2020-03-17 21:17:43 +0800

Seen: 8 times

Last updated: Mar 19 '20

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More