Different oLanguage strings dependent on variable value

Different oLanguage strings dependent on variable value

matbeardmatbeard Posts: 22Questions: 0Answers: 0
edited January 2012 in General
Is there a way I can change one of the language strings (sZeroRecords) dependent on the value of a variable?

I the table is designed to show child records associated with a parent record , so I want to differentiate between the parent record not being saved yet (parent record id=0 and no child records returned), and no child record being created (parent record id > 0 and no child records returned).

I've tried:
[code]
"oLanguage": function () {
if (iOrderId > 0) {
oLanguage.push ( {"sZeroRecords": "No items on this order."} );
} else {
oLanguage.push ( {"sZeroRecords": "The parent record is an unsave new record. Save it before adding items." } );
}
},
[/code]
but it just results in the default language string being displayed (doesn't throw any errors).

Any ideas?

Replies

  • allanallan Posts: 63,540Questions: 1Answers: 10,476 Site admin
    Currently - no there is no way of doing that - at least not quite like that. What you would need to do is define an fnDrawCallback function and check if the table is empty, If it is, then inject your own string over the top of the DataTables one, dependent on the condition.

    It is a nice idea for future though!

    Allan
  • matbeardmatbeard Posts: 22Questions: 0Answers: 0
    Thanks for the quick reply Allan. I'll fiddle with fnDrawCallback to see if I can get what I need.

    Thanks.
This discussion has been closed.