How to change feature values after DataTable is already initialized?
How to change feature values after DataTable is already initialized?
Hello,
I initialized a DataTable to be scrollable. This table has to fit into its container. It is hard to determine the value for "sScrollY" upfront. It should equal to container's height minus table header's height. I know container's height but don't know table header's height until they are rendered. So I need to calculate and change "sScrollY" value after DataTable is initialized. How do I change this value?
Here is my code to initialize DataTable. As you can see "sScrollY" is set to 200. It should be set again later.
[code]
var $dataTable = $(".search-result-table", $container).dataTable(
{
"bJQueryUI" : true,
"sScrollY" : 200,
"sScrollX" : "100%",
"bPaginate" : false,
"bFilter" : false,
"bSort" : false,
"bSortClasses" : false,
"bInfo" : false,
"sDom" : '<"result-list"t>',
"aoColumnDefs" : aoColumnDefs
});
[/code]
Thank you in advance.
I initialized a DataTable to be scrollable. This table has to fit into its container. It is hard to determine the value for "sScrollY" upfront. It should equal to container's height minus table header's height. I know container's height but don't know table header's height until they are rendered. So I need to calculate and change "sScrollY" value after DataTable is initialized. How do I change this value?
Here is my code to initialize DataTable. As you can see "sScrollY" is set to 200. It should be set again later.
[code]
var $dataTable = $(".search-result-table", $container).dataTable(
{
"bJQueryUI" : true,
"sScrollY" : 200,
"sScrollX" : "100%",
"bPaginate" : false,
"bFilter" : false,
"bSort" : false,
"bSortClasses" : false,
"bInfo" : false,
"sDom" : '<"result-list"t>',
"aoColumnDefs" : aoColumnDefs
});
[/code]
Thank you in advance.
This discussion has been closed.
Replies
This could be wrapped up into an API plug-in to make it slightly easier... :-)
Allan
If I only want to set sScrollY, can I skip sX? Thanks.
Ken
I think I found the answer myself. It is OK to only set the height and keep the initial sX. Thank you for your help.
Ken