Vino Dang Vino Dang - 3 months ago 68
AngularJS Question

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

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!

Answer

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