HOW TO CHECK DATA TABLE IS EMPTY OR NOT ???

HOW TO CHECK DATA TABLE IS EMPTY OR NOT ???

bharatmicrobharatmicro Posts: 6Questions: 0Answers: 0
edited May 2013 in General
can anybody tell how to check data table is empty or not .. e.g if table is empty then alert("is empty") and if not then alert("not empty")

Replies

  • MisiuMisiu Posts: 68Questions: 4Answers: 2
    edited May 2013
    [code]table.fnSettings().aoData.length[/code] gives You the length of data in table. So if it will be equal to 0 then there is no data.

    So You can do this:
    [code]
    if(table.fnSettings().aoData.length===0) {
    alert('no data');
    } else {
    alert('data exists!');
    }[/code]
  • bharatmicrobharatmicro Posts: 6Questions: 0Answers: 0
    Thanks lot Misiu.. i will try that... :)
  • allanallan Posts: 61,887Questions: 1Answers: 10,141 Site admin
    I'd suggest using fnGetData rather than a private variable from the settings object. fnGetData is a public API and will not change.

    Allan
This discussion has been closed.