fnDrawCallback on the fly
fnDrawCallback on the fly
How can i use fnDrawCallback on the fly after i initialize the dataTable object ?
[code]
oTable = $("#table").dataTable();
oTable.fnDrawCallback = someCallback;
[/code]
[code]
oTable = $("#table").dataTable();
oTable.fnDrawCallback = someCallback;
[/code]
This discussion has been closed.
Replies
Allan
Allan
okay i see, when i used oTable.fnSettings().fnInitComplete it solved. But when i used ajax processing with dataTable the problem is appear. The function is not defined. Take a look at my code:
PHP Generate Code
[code]
$table = Admin_Api_Core::getInstance()->ajaxTableDisplay(array(
'id' => 'listforum',
'columns' => $this->_columnTitles,
'dataTables' => array(
'bJQueryUI' => true,
'sPaginationType' => 'full_numbers',
'aoColumns' => array(
null,
array('sWidth' => '10%'),
null,
array('sClass' => 'center', 'sWidth' => '5%'),
null,
array('bSortable' => false, 'bSearchable' => false, 'sClass' => 'center', 'sWidth' => '12%')
),
'bProcessing' => true,
'bServerSide' => true,
'sAjaxSource' => $this->view->url(array('module' => 'admin', 'controller' => 'forums', 'action' => 'ajax'))
)
));
[/code]
PHP Parsing code
[code]
$script[] = '';
$script[] = '$(document).ready(function() {' . PHP_EOL;
$script[] = 'oTable = $("#' . $id . '").dataTable(' . json_encode($params) . ');' . PHP_EOL;
$script[] = 'oTable.fnSettings().fnInitComplete = renderButton;console.log(oTable.fnSettings())';
$script[] = '});';
[/code]
i can't reference javascript function into json_encode value, that's way i need a public API for fnDrawCallback
I solved that by using Zend_Json encoder function
[code]
$table = Admin_Api_Core::getInstance()->ajaxTableDisplay(array(
'id' => 'listforum',
'columns' => $this->_columnTitles,
'dataTables' => array(
'bJQueryUI' => true,
'sPaginationType' => 'full_numbers',
'aoColumns' => array(
null,
array('sWidth' => '10%'),
null,
array('sClass' => 'center', 'sWidth' => '5%'),
null,
array('bSortable' => false, 'bSearchable' => false, 'sClass' => 'center', 'sWidth' => '12%')
),
'bProcessing' => true,
'bServerSide' => true,
'sAjaxSource' => $this->view->url(array('module' => 'admin', 'controller' => 'forums', 'action' => 'ajax')),
'fnDrawCallback' => new Zend_Json_Expr('renderButton')
)
));
[/code]
thx allan