CheckBoxPanel checkBoxPanel = new CheckBoxPanel(componentId);


Which model do you pass to the CheckBoxPanel?

Sven

On 07/15/2013 01:28 PM, wicket_user_100 wrote:
Hi All,

I'm trying to add select All Checkbox to the header of wicket DataTable
column, I've read that I need to use CheckGroup and CheckGroupSelector. I'm
doing the following:

Form form = new Form("form");

CheckGroup group = new CheckGroup("group");
    group.add(new CheckGroupSelector("groupselector"));
    DataTable sourceTable = new DataTable("mytable", getColumns(),
getDataProvider(), 10);
    sourceTable.setOutputMarkupPlaceholderTag(true);
    group.add(sourceTable);
    add(form);
    form.add(group);


private List getColumns() {
         List<IColumn&lt;MyItem, String>> ret = Lists.newArrayList();
         ret.add(new AbstractColumn<MyItem, String>(new Model<>("")) {
             @Override
             public void populateItem(Item<ICellPopulator&lt;MyItem>>
cellItem, String componentId, IModel<MyItem> rowModel) {
                 CheckBoxPanel checkBoxPanel = new
CheckBoxPanel(componentId);
                 cellItem.add(checkBoxPanel);
             }
         });
...
}


<input type="checkbox" wicket:id="groupselector">check/uncheck all</input>
[Lookup Results]



To add CheckBox to the DataTable I must use a Panel, so I have the
following:
public class CheckBoxPanel extends Panel {

     private CheckBox field;

     public CheckBoxPanel(String id, IModel<Boolean> model) {
         super(id);
         field = new CheckBox("checkBox", model);
         add(field);
     }

     public CheckBoxPanel(String id) {
         this(id, new Model<Boolean>());
     }

     public CheckBox getField() {
         return field;
     }
}

In CheckBoxPanel.html

<body>
     <wicket:panel xmlns:wicket="http://wicket.apache.org";>
         <input type="checkbox" wicket:id="checkBox">
     </wicket:panel>
</body>

Actually it does show checkgroup but under my table and checking/un-checking
it does not affect the check boxes under it. What am I doing wrong here?



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/how-to-add-select-deselect-all-checkbox-to-wicket-DataTable-tp4660270.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to