Stop Display of "No data available in table"

Stop Display of "No data available in table"

dickbobdickbob Posts: 10Questions: 0Answers: 0
edited May 2012 in General
Initially my table has no data and I get "No data available in table" which is the expected functionality.

I'd like to have no text or row created as I will be populating the table via Ajax depending on user action.

Is there a setting to stop the display of this row in the table? I can't seem to find one.

TIA

Richard

Replies

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    Sounds like sLoadingRecords might be what you want: http://datatables.net/ref#sLoadingRecords .

    Allan
  • dickbobdickbob Posts: 10Questions: 0Answers: 0
    Thanks for your swift thoughts but no joy. I've seen that before when server-side data has been slow to be delivered.

    I've also tried sEmptyTable and sZeroRecords with them set to an empty string but they still return a default string in the row I don't want to see.
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    Which version of DataTables are you using?

    Allan
  • dickbobdickbob Posts: 10Questions: 0Answers: 0
    1.9.0
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    Hmmm - that should work okay. Can you give me a link to the page please?

    Allan
  • dickbobdickbob Posts: 10Questions: 0Answers: 0
    Sorry for the delay in coming back to you. Project pressures! :-)

    This is for an intranet site so no accessible page available but here are some code snippets...

    [code]$('#courseBlockListing').dataTable({"bInfo":false
    ,"bLengthChange":false
    ,"bFilter":false
    ,"bPaginate":false
    ,"bSort": false
    ,"oLanguage": {"sZeroRecords": "", "sEmptyTable": ""}
    });[/code]

    [code]


    No
    Course
    Year
    Level
    Required
    Credits
     





    [/code]

    ...which produces the following generated HTML...

    [code]


    No
    Course
    Year
    Level
    Required
    Credits
     








    [/code]

    ...and I don't want that empty row/cell in the table body to be rendered.

    Thoughts?
  • dickbobdickbob Posts: 10Questions: 0Answers: 0
    I've styled out (display:none) the "dataTables_empty" class in the short term to get over this issue whilst a more robust solution is considered.
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    > ...and I don't want that empty row/cell in the table body to be rendered.

    I see - at the moment DataTables doesn't offer an option for that. I don't remember coming across such a requirement before, but I will put it on the feature list queue and watch for any other requests for this particular future. Until then, your display:none method sounds like a good solution :-)

    Allan
  • dickbobdickbob Posts: 10Questions: 0Answers: 0
    Glad I've managed to express myself clearly this time! :-)

    It's just that I want to populate the tbody via Ajax after the page has been initially rendered so don't what there to be anything initially in there.

    I'll keep an eye out for future releases and hope it makes it :-)

    Thanks once again for your time and efforts ($25 private donation made).
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    Thanks very much for the donation! Hugely appreciated :-)

    One option I've just thought of, is that you could use fnDrawCallback on the first draw (before initialisation is complete when doing an Ajax call) to remove the "spare" element. This example shows how that might be done: http://live.datatables.net/umumah/edit#javascript,html .

    Thinking some more on this... you could do this: http://live.datatables.net/umumah/2/edit - no need for fnDrawCallback since the Ajax is async - while the empty() call it not :-)

    Regards,
    Allan
  • dickbobdickbob Posts: 10Questions: 0Answers: 0
    Thanks for the .empty() suggestion. That works nicely!
This discussion has been closed.