Limit the text in column
Limit the text in column
Hello my name is Rudy and this is my first post.
I need to strip the text into the column with a maximum number of letters up to 350.
I have read that about mRender function but I am a bit stuck about its use.
I work with Datatables in a CakePhp project, my DT is already built under the MVC pattern of cakephp.
I will enclose my script to better clear what I need
[code]
$('#admin_index_table').dataTable({
aoColumns: [
{ mData: 'Family.id' },
{ mData: 'Family.name' },
{ mData: 'Family.description' },
{ mData: 'Family.created' },
{ mData: 'Family.enabled' },
{
mData: 'Family.id',
mRender: <?php echo $this->DataTables->renderActions(); ?>,
bSortable: false,
bSearchable: false
}
]
});
[/code]
any hint ?
Thanks in advance
Rudy
I need to strip the text into the column with a maximum number of letters up to 350.
I have read that about mRender function but I am a bit stuck about its use.
I work with Datatables in a CakePhp project, my DT is already built under the MVC pattern of cakephp.
I will enclose my script to better clear what I need
[code]
$('#admin_index_table').dataTable({
aoColumns: [
{ mData: 'Family.id' },
{ mData: 'Family.name' },
{ mData: 'Family.description' },
{ mData: 'Family.created' },
{ mData: 'Family.enabled' },
{
mData: 'Family.id',
mRender: <?php echo $this->DataTables->renderActions(); ?>,
bSortable: false,
bSearchable: false
}
]
});
[/code]
any hint ?
Thanks in advance
Rudy
This discussion has been closed.
Replies
mData: 'Family.description',
mRender: function ( data, type, row ) {
if ( data.length > 350 ) {
return data.substr( 0, 350 )+'...';
}
return data;
}
[/code]
Note that `data` in mRender is whatever the mData option resolves the data to be.
Allan