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

The Oracle JDeveloper forum ranks in the Top 5 of the most active forums on the Oracle Technology Network (OTN).



The OTN Harvest blog is a summary of selected topics posted on the OTN Oracle JDeveloper forum.



It is an effort to turn knowledge exchange into an interesting read for developers who enjoy little nuggets of wisdom





Frank Nimphius

Search

Archives
« April 2014
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
   
       
Today