Style attribute being added to DataTable.

Style attribute being added to DataTable.

IsaacLIsaacL Posts: 4Questions: 2Answers: 0

Hello!

I'm using DataTables 1.10.7.

Right now I'm dynamically generating the rows to a table using AJAX, and then invoking DataTables upon it. Sometimes this works well, and other times the table tag gains a mysterious attribute: "style="width: 620px;" Are there any obvious reasons why this might be?

A correlation I found with this issue is that when DataTables is invoked for the first time immediately following a jQuery animation which slides horizontally. If the two are related, is there any way I can keep the animation, but dash the style tag?

Answers

  • IsaacLIsaacL Posts: 4Questions: 2Answers: 0

    I ended up just overwriting the style attribute with another style attribute in JavaScript, but I'd like a cleaner solution that doesn't add the style attribute in the first place.

  • ThomDThomD Posts: 334Questions: 11Answers: 43
    edited September 2015

    it doesn't sound like DT is the one adding the style. You'll need to figureout exactly where that inline style is coming from before you can figure out how to stop it.

    You haven't posted any sample code, so any suggestions would be blind guesses.

  • mtuckermtucker Posts: 2Questions: 0Answers: 0

    Here is a sample JS Bin that shows this:
    http://live.datatables.net/fiwiriyu/4/

    The blue shaded area shows the parent container. When you resize the width so that Position is the last column, then you will notice the horizontal scroll bar. The width of the div (#example_wrapper) will be smaller (ex: 720px) than the table (#example) which in this example is 945px. The style of the table is explicitly set:

    <

    table id="example" class="table table-bordered dataTable no-footer collapsed" role="grid" aria-describedby="example_info" style="width: 945px;">

This discussion has been closed.