Friday Jan 20, 2012

Adding checkboxes to sortable table headers

Using the header facet of the af:column tag, developers can add components to the table header, for example to indicate the component to be excluded from printing or export to Excel. The side effect of adding a command item to a table header is when the table column is sortable.

In this case, selecting the component, for example an instance of af:selectBooleanCheckBox , will also trigger sorting on the table, which you don't want to happen until users explicitly ask for this.

The solution to this problem is JavaScript added to the checkbox components and the use of stopBubbling() to prevent user the click event to reach the table header and then the sort icons.

<af:resource type="javascript">
   function stopBubbling(evt){
      evt.stopBubbling();
  }
</af:resource> 

The JavaScript is called from the checkbox as shown below

<af:selectBooleanCheckbox id="sbc2" text="FirstName"                                                           
                          value="..." autoSubmit="true">
 <af:clientListener method="stopBubbling" type="click"/>
</af:selectBooleanCheckbox>

About

A blog on Oracle JDeveloper, ADF, MAF, MCS and other mobile and web topics inspired by questions and answers posted on the OTN forums.



Frank Nimphius

Search

Archives
« May 2015
SunMonTueWedThuFriSat
     
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
      
Today