0

Multiple selections with grid

asked 2015-01-13 17:02:56 +0800

Antoc gravatar image Antoc
21 4

Hi everybody, I want to develop an application that uses a grid for displaying a specific set of data. I want to provide a bulk close functionality where users can select all the items in the present page (not all the pages) and then perform a closure operation for all of these items. This approach is very similar to the one offered in Google mail. The grid is displayed below:

<button label="Close" id="bulkclose" sclass="button"/>
<grid id="grid" sclass="grid"
     height="100%"
     width="100%"
     emptyMessage="Nothing in Data List."
     mold="paging"
     pagingPosition="bottom"
     autopaging="true">

      <columns width="5%">
        <column width="3%" label="" valign="center" align="center"><checkbox id="selectAll"/></column>
        <column width="3%" label=""/>
        <column width="6%" label="ID" align="left"/>
        <column width="11%" label="CREATED DATE" align="left"/>
        <column width="5%" label="CATEGORY" align="left"/>
        <column width="8%" label="CLOSED DATE" align="left"/>
        <column width="10%" label="USER" align="left"/>
        <column width="8%" align="center" label=""/>
      </columns>
</grid>

In the controller class I have implemented the following method for the selectAll checkmark.

public void onCheck$selectAll(Event evt) {
    if (isSelectedAll == false) {

        if (alerts != null && alerts.size() > 0) {
            for (Alert alert : alerts) {
                alert.setChecked(true);
            }
            bulkclose.setVisible(true);
            grid.setModel(alerts);
        }
        isSelectedAll = true;

    } else {
        if (alerts != null && alerts.size() > 0) {
            for (alert alert : alerts) {
                alert.setChecked(false);
            }
            bulkclose.setVisible(false);
            grid.setModel(alerts);
        }
        isSelectedAll = false;
    }

}

With this code I am able to perform a bulk selection for ALL the items in the grid (in all the pages) but I can't find a way to do so for the current page only. I need to use a grid, the listbox cannot be used. Any thought?

delete flag offensive retag edit

Comments

grid.getPaginal? You could have the current page and pagesize from that. Count it out untill you have first and last index of you model.

chillworld ( 2015-01-15 23:19:52 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-01-18 20:49:11 +0800

Darksu gravatar image Darksu
1991 1 4

Hello Antoc,

Since you want only the selected items for the current page you could use a paging component where on each onPage change event you could reset the selected items to unselected.

Best Regards,

Darksu

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: 2015-01-13 17:02:56 +0800

Seen: 19 times

Last updated: Jan 18 '15

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