具有过滤器列宽的角度数据表

时间:2022-02-12 14:27:49

I tried to set width for column in angular datatables with filters. But width of the column not changed.

我试图在带有滤镜的角度数据表中为列设置宽度。但是列的宽度没有改变。

I try following

我试着跟着

   var columnsSpecification = [
      {
          type: 'text',
          bRegex: true,
          bSmart: true
      }, {
          type: 'text',
          bRegex: true,
          sWidth:"90px"}];


    $scope.dtOptions = DTOptionsBuilder.newOptions()
      .withBootstrap()
      .withOption('scrollX', '700%')
      .withOption('scrollY', height + 'px')
      .withOption('oLanguage', { "sEmptyTable": " " })
      .withOption('lengthMenu', [[-1, 1000, 100, 50, 25, 10], ['All', 1000, 100, 50, 25, 10]])
      .withOption('paging', false)
      .withOption('bInfo',false)
      .withColumnFilter({          
      aoColumns:columnsSpecification 
  })
  .withTableTools('/Content/DataTables/swf/copy_csv_xls.swf')
  .withTableToolsButtons(['xls']);

In html file I tried this:

在html文件中我试过这个:

   <table id="table-machines" datatable="ng" class="table table-striped" dt-options="dtOptions">
    <thead>
        <tr>
            <th>Name</th>
            <th style="width: 90px !important">Value</th>                
        </tr>
    </thead>
    <tbody>
        <tr ng-repeat="m in records>
            <td>{{m.name}}</td>
            <td style="width: 90px !important">{{m.Value}}</td>                
        </tr>
    </tbody>

But Value column another zise rather I setted.

但是Value列出了另一个zise,而不是我设置的。

I'v found, that if there is not filter - all fine.

我发现,如果没有过滤器 - 一切都很好。

How can I set table width and preserve filters?

如何设置表格宽度并保留过滤器?

3 个解决方案

#1


9  

vm.dtColumns = [
        DTColumnBuilder.newColumn('id').withTitle('ID').withOption('width', '5%')
    ];

#2


0  

You need to define the option width in your columnDefs option:

您需要在columnDefs选项中定义选项宽度:

vm.dtColumnDefs = [
    DTColumnBuilder.newColumn(1).withOption('width', '90px')
  ];

See this example.

看这个例子。

#3


0  

Finally I've found the solution for avoiding datatables overwrite bootstrap columns width definitions:

最后我发现避免数据表覆盖引导列宽度定义的解决方案:

$scope.dtOptions = DTOptionsBuilder.newOptions()
    .withOption('autoWidth', false)

It was as easy as put that name and set to false... but it in the API doesn't appear to be available :(

它就像放入该名称一样容易并设置为false ...但它在API中似乎不可用:(

#1


9  

vm.dtColumns = [
        DTColumnBuilder.newColumn('id').withTitle('ID').withOption('width', '5%')
    ];

#2


0  

You need to define the option width in your columnDefs option:

您需要在columnDefs选项中定义选项宽度:

vm.dtColumnDefs = [
    DTColumnBuilder.newColumn(1).withOption('width', '90px')
  ];

See this example.

看这个例子。

#3


0  

Finally I've found the solution for avoiding datatables overwrite bootstrap columns width definitions:

最后我发现避免数据表覆盖引导列宽度定义的解决方案:

$scope.dtOptions = DTOptionsBuilder.newOptions()
    .withOption('autoWidth', false)

It was as easy as put that name and set to false... but it in the API doesn't appear to be available :(

它就像放入该名称一样容易并设置为false ...但它在API中似乎不可用:(