Limit the text in column

Limit the text in column

rudy1976srudy1976s Posts: 1Questions: 0Answers: 0
edited February 2013 in General
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

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    edited February 2013
    [code]
    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
This discussion has been closed.