Truncate column content via jTruncate (JSON)

Truncate column content via jTruncate (JSON)

andi_sfandi_sf Posts: 7Questions: 0Answers: 0
edited July 2012 in DataTables 1.9
I have set up in my JSON data source a class wrapped around text.

I now like to truncate this text via jTruncate (http://www.jeremymartin.name/projects.php?project=jTruncate).
I have accomplish that with:

[code] "fnInitComplete": function(oSettings, json) {
$('.doc-desc').jTruncate();
} [/code]

but this works only on the initially loaded first results page - on subsequent paginated results the text is not truncated any more. Any help would be greatly appreciated... thanks in advance!

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    edited July 2012
    Try:

    [code]
    "fnInitComplete": function(oSettings, json) {
    this.$('.doc-desc').jTruncate();
    }
    [/code]

    *edit* - this is why: http://datatables.net/faqs#events

    Allan
  • andi_sfandi_sf Posts: 7Questions: 0Answers: 0
    Hi Allan,

    thank you so much - this worked like a charm -you are a life saver!
  • harvey68harvey68 Posts: 2Questions: 0Answers: 0
    Hi Allan,

    I tested this, it works for the first json page (sAjaxSource). But the next page will be as "usual".

    Is there a solution for server-side display of data?

    yours
    Alexander
  • harvey68harvey68 Posts: 2Questions: 0Answers: 0
    Hi Allan,

    Sorry I did not try enough before posting, here is my solution for server-side display:

    [code]
    "fnInfoCallback": function( oSettings, iStart, iEnd, iMax, iTotal, sPre ) {
    this.$('.doc-desc').jTruncate({length: 5, minTrail:0, moreText:""});
    },
    [/code]

    yours
    Alexander
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    I'd suggest fnDrawCallback for something that needs to happen on each draw :-)

    Allan
This discussion has been closed.