ui-grid cannot rendered correctly when using ng-show/ng-hide, if you press F12 on the keyboard, it c

不管现实多么惨不忍睹,都要持之以恒地相信,这只是黎明前短暂的黑暗而已。不要惶恐眼前的难关迈不过去,不要担心此刻的付出没有回报,别再花时间等待天降好运。真诚做人,努力做事!你想要的,岁月都会给你。ui-grid cannot rendered correctly when using ng-show/ng-hide, if you press F12 on the keyboard, it c,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com,来源:原文

My code is as below:

<div class="gridStyle" ng-grid="gridOptions" ng-show="flag"></div>

when i set the flag to true, the grid cannot render correctly, if you press F12 on the keyboard, it can show correctly!

share

edit

close

delete

flag
 
 
ng-grid also has this issue! – 
Vino Dang 
Oct 14 ’15 at 10:27   

 
what do you mean by Correctly? doesnt show at all? – 
Ori Price 
Oct 14 ’15 at 10:32
 
does it show correctly if you resize your browser window? if that’s the case then you might need to call gridApi.core.refresh(); when you change your flag variable (that’s for ui-grid. for ng-grid i think you need to call gridOptions.ngGrid.buildColumns(); ) – 
valepu 
Oct 14 ’15 at 11:40 
 
@OriPrice, it means the page displays incorrectly. – 
Vino Dang 
Oct 15 ’15 at 3:37   

1  
@valepu,yes, when i resize my browser window, it can show correctly! For grid i use the $scope.gridOptions.ngGrid.buildColumns(), it show correctly! Thank u very much! – 
Vino Dang 
Oct 15 ’15 at 3:55   

 
 

3 Answers

ng-grid and ui-grid don’t automatically update the table when hidden or shown. By calling gridApi.core.refresh(); (for ui-grid) and gridOptions.ngGrid.buildColumns(); (for ng-grid) you force the library to rebuild the table according to the current DOM situation

share

edit

flag
 
 
Thank u very much! it works! – 
Vino Dang 
Oct 21 ’15 at 3:25   

 
remember to accept the answer if it’s been of help – 
valepu 
Oct 21 ’15 at 9:22
 
ok, i have done it, thx – 
Vino Dang 
Oct 21 ’15 at 12:28   

 

While I realize this question has aged, none of the solutions worked for me as of today. However, using the ui-grid-auto-resize attribute on my element worked like a charm.

<div ui-grid="gridOptions" class="grid" ui-grid-auto-resize></div>

share

edit

flag
 
 
As per the docs ui-grid.info/docs/#/tutorial/108_hidden_grids setting a width and height worked for me. – 
vanzylv 
Oct 24 ’16 at 12:20
 

i also find a solution: use ng-if instead of ng-show/ng-hide, like this:

<div class="gridStyle" ng-grid="gridOptions" ng-if="flag"></div>

Using ng-if also fiexed it for me!

share

edit

delete

flag
 


更多信息,请查看我的stackoverflow: http://stackoverflow.com/questions/33122848/ui-grid-cannot-rendered-correctly-when-using-ng-show-ng-hide-if-you-press-f12-o



版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/164238.html

(0)
飞熊的头像飞熊bm

相关推荐

发表回复

登录后才能评论
极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!