简体   繁体   English

如何根据数据调整角度数据表的高度

[英]How to adjust height of angular datatable based on data

I am facing an issue in adjusting the height of the datatable when the webservice is called to populate the same. 当调用webservice填充数据表时,我在调整数据表的高度时遇到问题。

I have a page that contains a collapsible div and a datatable . 我有一个页面,其中包含一个可折叠的div和一个datatable When the I collapse the div, I calculate the height and resize the table using inline CSS. 当我折叠div时,我使用嵌入式CSS计算高度并调整表格的大小。 However, whenever I call the webservice to populate the data, the data table again shrinks back to a smaller size (the size it has in expanded state). 但是,每当我调用Web服务填充数据时,数据表就会再次缩小到较小的大小(处于扩展状态的大小)。

I want to know how to adjust the height of the datatable dynamically. 我想知道如何动态调整数据表的高度。 I cant share much of the code here due to certain client constraints. 由于某些客户端的限制,我在这里无法共享很多代码。

Here is how I assign the height 这是我分配高度的方法

tableHght.css({ 'height': yLength + 'px', 'overflow': 'auto', 'width': '100%' });`

YOu can do so by using ng-class directive as follows:- 您可以通过使用ng-class指令执行以下操作:

<div class="yourTable" ng-style="{ 'height': yourModelToProvideValue }">

in the controller 在控制器中

$scope.yourModelToProvideValue = "200px" ;

or simply 或简单地

<div class="yourTable" ng-style="yourModelToProvideValue">

and in the controller 并在控制器中

$scope.yourModelToProvideValue = "height : 200px" ;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM