当NG-隐藏从无形到有形NG-格变化知名度,格宽度不被重新计算 [英] When ng-grid change visibility from invisible to visible by ng-hide, grid width not being re-calculated

查看:185
本文介绍了当NG-隐藏从无形到有形NG-格变化知名度,格宽度不被重新计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个NG-网格NG隐藏属性,宽度:100%样式

I have a ng-grid with ng-hide attribute and width:100% style.

<div class="grid-style" data-ng-grid="gridOpt"
  style="display: inline-block; height: 300px; width: 100%;">
</div>

这就是格,在第一时间不见了踪影,可见后,我选择在我的HTML表单中的一些选项。
当该网格变得可见,它的宽度是错误的。

This grid is invisible at first time, and become visible after I select some option in my HTML form. When this grid become visible, it's width is wrong.

有没有什么办法来强制更新网格布局?

Are there any approach to force update Grid's layout ?

推荐答案

我有同样的问题。也许这就是这个问题有关。我创建了一个新的指令作为一种解决方法:

I had the same issue. Maybe it is related to this issue. I created a new directive as a workaround:

myDirectives.directive('resizeWhen', function () {
    'use strict';
    return {
        restrict: 'A',
        scope: false,
        link: function (scope, elem, attrs, ctrl) {
            var resizeExpr = attrs.resizeWhen,
            listener = scope.$watch(resizeExpr, function (value) {
                if (value) {
                    elem.resize(); 
                    listener();
                }
            }, false);
        }
    };
});

您可以使用此类似如下:

You can use this like the following:

<div id="searchResultsGrid" ng-grid="searchResultsGrid" 
     resize-when="mode == 'search'">
</div>

请注意,你需要的jQuery对上述指令工作。

Note, that you need jQuery for the above directive to work.

这篇关于当NG-隐藏从无形到有形NG-格变化知名度,格宽度不被重新计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆