Conditional Formatting within oLanguage > sInfo?

Conditional Formatting within oLanguage > sInfo?

FWeirFWeir Posts: 3Questions: 0Answers: 0
edited April 2013 in General
I am making some small tweaks to a DataTable entry, and came across this small problem - if the _TOTAL_ is anything other than one, it makes sense, but if my number of records just so happens to be one, the phrase just doesn't make sense - "There are 1 people in this Role"?

Is there any way to change sInfo if _TOTAL_ is 1?

[code]
$("#sqepMatrix").dataTable({
"bJQueryUI": true,
"bPaginate": false,
"oLanguage": {
"sInfo": "There are _TOTAL_ people in this Role."
},
"sPaginationType": "full_numbers"
});[/code]

Any ideas are very welcome!

Felix

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    You could use fnInfoCallback for this.

    I do need to add plural support to the core at some point... Bookmarked to remind me.

    Allan
  • FWeirFWeir Posts: 3Questions: 0Answers: 0
    edited April 2013
    Gee, it isn't pretty but it worked like a charm! Updated code for anyone that may stumble across this with a similar problem in the future:

    [code]
    $("#sqepMatrix").dataTable({
    "bJQueryUI": true,
    "bPaginate": false,

    "sPaginationType": "full_numbers",
    "fnInfoCallback": function (oSettings, iTotal) {
    if (iTotal == 1) {
    return "There is one person in this Role.";
    }
    else {
    return "There are " + iTotal + " people in the Role.";
    }
    }
    });
    [/code]
  • FWeirFWeir Posts: 3Questions: 0Answers: 0
    edited April 2013
    Well it seems that this won't work when using multiple tables, as once the first instance has been decided, it will use the same string every time, regardless of differing totals... oh well.
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    I don't understand I'm afraid. Can you link me to a test page showing the problem so I can fix it?

    Allan
This discussion has been closed.