Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery数据表宽度保持重置_Javascript_Jquery_Html_Angularjs_Datatables - Fatal编程技术网

Javascript jQuery数据表宽度保持重置

Javascript jQuery数据表宽度保持重置,javascript,jquery,html,angularjs,datatables,Javascript,Jquery,Html,Angularjs,Datatables,我正在使用jquery向HTML表添加功能。我想将宽度设置为固定的%值。它可以工作,但每当我更改“Show x entries”(显示x个条目)下拉列表(该下拉列表更改要在更改中显示的条目数)时,宽度都会重置。如何停止此重置 编辑:我认为当某些td元素非常大(300多个字符)时会发生这种情况。但不知道如何解决这个问题 Html(使用angularjs框架,但这不重要): 指令js angular.module('myApp') .directive('repeatDone', function(

我正在使用jquery向HTML表添加功能。我想将宽度设置为固定的%值。它可以工作,但每当我更改“Show x entries”(显示x个条目)下拉列表(该下拉列表更改要在更改中显示的条目数)时,宽度都会重置。如何停止此重置

编辑:我认为当某些td元素非常大(300多个字符)时会发生这种情况。但不知道如何解决这个问题

Html(使用angularjs框架,但这不重要):

指令js

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%"}
    ]
});
    $('#my-table').DataTable({
    "autoWidth": false,
    "columns": [
        {"width": "20%"},
        {"width": "5%"},
        {"width": "25%"},
        {"width": "50%"}
    ]
});
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%"}
    ]
});