I was able to do this by separating the columnDefs from the initialization code. And passing the columndfs variable through the custom tag. Thank you.
Creating custom JSP tag for jquery datatable
-
14-10-2022 - |
Question
I have a jquery datatable as initialized below:
$(document).ready(
function() {
var oTable = $('#paginatedTable').dataTable( {
"bServerSide" :true,
"sAjaxSource" :"/JQueryPagination/Myservlet",
"bProcessing" :true,
"sPaginationType" :"full_numbers",
"bJQueryUI" :false,
"aoColumns" : [ {
"sTitle" :"CBox",
"mData" :"Name",
"bSortable": false,
"mRender" : function(data, type, full) {
return '<input type=\"checkbox\" onClick= myCheckBoxSel(this); value="' + data + '"id="ChkBox">';
}
}, {
"sTitle" :"Name",
"mData" :"Name",
"mRender" : function(data, type, full) {
return '<a href="/JQueryPagination/MyservletLink?Name=' +data+ '">' + data + '</a>';
}
}, {
"sTitle" :"Address",
"mData" :"Address"
}, {
"sTitle" :"Town",
"mData" :"Town"
}
]
});
});
Now I would like to create a custom jsp tag that would generate the same initialization code for me. Something like this.
<custom:jDataTable id="custDataTable" tableName="paginatedTable" bProcessing = "true" bServerSide="true" sAjaxSource="/JQueryPagination/Myservlet" paginationType="full_numbers"/>
But here I'm not able to figure out how to specify the column definitions through the custom tag. Any help is highly appreciated. Thanks in advance.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow