I'm using Primefaces 3.5RC. I am having trouble implementing the following JS function to enable me to freeze columns on a dataTable. I'm still new to JS and don't know how I should reference my dataTable id within the Example JS functions below that I found on StackOverflow: Column Freeze or Fixed Column in datatable . Any help or suggestions will be greatly appreciated. Thanks.
var oTable2 = $(primfacesDataTableId).find('table').dataTable({
"sScrollX" : "100%", //Scroll
"sScrollY" : "180",
"bAutoWidth" : false,
"bScrollCollapse" : true,
"bPaginate" : false,
"bSort" : false,
"sInfo" : "",
"sInfoEmpty" : ""
});
var oFC = new FixedColumns(oTable2, {
"iLeftColumns" : 4, //Freezed first for columns
"sHeightMatch" : "auto",
"iLeftWidth" : 405
});
Usually you refer the Primeface/JSF components from the parent form component.
For Example:
If you have following code:
<h:form id="myForm">
<p:dataTable id="myTable">
.....
</p:dataTable>
</h:form>
Refer your DataTable as:
myForm:myTable
Or you can get it from Firebug Console in your browser.
While you are referring to the component form JQuery use:
$("[id='myForm:myTable']")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.