Closed shotokai closed 11 years ago
After looking at the DataTableHelperI realized that the javascript options is the 3rd argument in DataTableHelper::render , so:
$js_options = array();
$js_options['sPaginationType'] = 'full_numbers';
echo $this->DataTable->render(null, array(), $js_options);
does the trick for the specific question I had. My question now is f I wanted to set these in the controller, could I?
I'm trying to add a function for add checkboxes:
'aoColumnDefs' => array(
'aTargets' => array(0),
'fRender' => 'function ( oObj ) {
return \'<input id="chkBox" name="chkBox" value="\'+ oObj.aData[0] +\'" type="checkbox" checked="" />\';
}'
)
but the function is output scaped and does not work, how can add a function ?
Thanks!
@shotokai Yes (I think).
In your controller:
class MyController {
public $helpers = array(
'DataTable.DataTable' => array(
'js' => array(
'sPaginationType' => 'full_numbers',
),
),
);
}
Apologies for the very, very late response.
@xeongt That's an issue with json_encode not being able to encode functions.
What you can do instead is manually init the datatables and use the global dataTableSettings
js var to add your fender
function.
Use the console in your browser to see what dataTableSettings
looks like, then you'll be able to add what you need to it, and finally call $('#mytable').dataTable(dataTableSettings['ModelName'])
If you have any more questions, open a new issue please. I'll try my best to respond quicker.
Marking as closed. Re-open if it doesn't work @shotokai
Awesome Plugin. Many thanks!
I'm trying to figure out how to modify the Initialization code. For instance if I wanted full pagers, I would initialize with:
What is the correct way to do this using your plugin?