1

I am using the DataTables plugin on multiple pages of my site and when no records are found I need it to display a different message on each page.

Right Now I use the below for the current message:

"oLanguage": {
        "sEmptyTable": "There is no data available for the week selected."
}

Is there some way to maybe put a conditional statement inside of oLanguage that checks for the current page? Something like:

if (currentPage == "thisPage")
    "sEmptyTable" : "There is no data on this current page"

1 Answer 1

2

I don't know if this trick works with Datatables, but you could try to pass the "sEmptyTable" as a function:

"oLanguage": {
    "sEmptyTable": function(){ return "There is no data"; }
}

See this fiddle http://jsfiddle.net/tRTkd/ for a demo that sets the text of a button.

Sign up to request clarification or add additional context in comments.

1 Comment

Worked great! Thanks! I just created the function, did the logic in the function, and called it from "sEmptyTable".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.