width keeps resetting even with autowidth set

width keeps resetting even with autowidth set

testdatatables1testdatatables1 Posts: 1Questions: 1Answers: 0
edited December 2016 in Free community support

I want to set the width to a fixed % value. It works, but whenever I change the "Show x entries" dropdown which changes the number of entries to display on the change, the width resets. How can I stop this reset?

Html (using angularjs framework, though that shouldn't matter):

    <table ng-if="itms && itms.length > 0" id="my-table" class="table table-striped" cellspacing="0">
    <thead>
        <tr>
            <th>c1</th>
            <th>c2</th>
            <th>c3</th>
            <th>c4</th>
        </tr>
    </thead>
    <tfoot>
        <tr>
            <th>c1</th>
            <th>c2</th>
            <th>c3</th>
            <th>c4</th>
        </tr>
    </tfoot>
    <tbody>
        <tr ng-repeat="itm in itms track by $index" repeat-done>
            <td>{{itm.c1}}</td>
            <td>{{itm.c2}}</td>
            <td>{{itm.c3}}</td>
            <td>{{itm.c4}}</td>
        </tr>
    </tbody>
</table>

Javascript:

angular.module('myApp')
.directive('repeatDone', function($timeout) {
        return function(scope, element, attrs) {
        if (scope.$last) {
            $timeout(callback1);
        }
}
});
function callback1(){
    $('#my-table').DataTable({
    "autoWidth": false,
    "columns": [
        {"width": "20%"},
        {"width": "5%"},
        {"width": "25%"},
        {"width": "50%"}
    ]
});

}

Answers

  • allanallan Posts: 63,550Questions: 1Answers: 10,476 Site admin

    Thanks for your question - however, per the forum rules can you link to a test case showing the issue please. This will allow the issue to be debugged.

    Information on how to create a test page, if you can't provide a link to your own page can be found here.

    Thanks,
    Allan

This discussion has been closed.