Displaying DataTables table on button click

Displaying DataTables table on button click

JLyon60JLyon60 Posts: 12Questions: 6Answers: 1

Okay, this may be a dumb question, but Is there a way to display a DataTables table once a user has clicked a button or menu item?

Here is the original jsfiddle from before I started trying to toggle the table: https://jsfiddle.net/jenlyon60/75fs3sbq/

So after I got the table created, I then tried adding an ID on the div containing my table, and set things so that that div defaulted to "display:none"; I then added a 3-line function (triggered by an "onclick" on the button) that just does a show. But it doesn't work, as shown by this fiddle https://jsfiddle.net/jenlyon60/3g393k2y/

I am not sure if there's an event conflict going on or what.

I had in mind that perhaps a better approach would be to fire the creation of the DataTables table when the button is clicked.

Thanks in advance.

This question has an accepted answers - jump to answer

Answers

  • bindridbindrid Posts: 730Questions: 0Answers: 119
    edited July 2017

    I put style='display:none' on the table, itself.

    then right before I call the DataTable to create the table I remove the display : none attribute.

  • bindridbindrid Posts: 730Questions: 0Answers: 119
    Answer ✓
  • JLyon60JLyon60 Posts: 12Questions: 6Answers: 1

    Thanks much!

    The basic concept works great, and I was able to reproduce it as a test HTML file. Unfortunately, I've got a couple other issues because the application that the code will go into is a SharePoint ASPX page, and I think that's now throwing a couple of monkey wrenches in the equation.

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    @JLyon60, I have been lucky so far. Even though we are a sharepoint shop, I have managed to state completely out of it and work on the aspx .net side :)

This discussion has been closed.