ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

using a url in cellTemplate in columnDef causes grid to malfunctions.

Open joshmackey opened this issue 12 years ago • 9 comments

If I include the html inline, it works fine, but as soon as its a remote file, the entire grid malfunctions having the headers be only a few pixels in height and the contents of the grid be invisible.

joshmackey avatar Nov 10 '14 19:11 joshmackey

Which version are you using?

PaulL1 avatar Nov 12 '14 21:11 PaulL1

Reported on rc14, but similar issues happens on rc15.

On rc15, the grid contents show, but the header is still only a few pixels in height.

joshmackey avatar Nov 12 '14 22:11 joshmackey

Here's a plunker demonstrating the problem: http://plnkr.co/edit/vXitx2XI5aLvG2YCRY4c?p=preview I think it may have something to do with leading/trailing whitespace in the cellTemplate when trying to $compile it. Investigating...

c0bra avatar Nov 13 '14 18:11 c0bra

OK, the leading and trailing whitespace is not a problem. It's purely the remote $http call that is causing the cell to be blank...

c0bra avatar Nov 13 '14 19:11 c0bra

Got it, I think. The problem is right here: https://github.com/angular-ui/ng-grid/blob/c19ffb101e86e02836dd3b9c760e9f769197e363/src/js/core/directives/ui-grid.js#L79

The dataWatchFunction gets called twice. First with an empty array, then with an array containing the data from the $http call. The problem is that the promises are getting resolved out of order. So the callback for the empty array is occuring AFTER the callback with the data. Your data gets set, then it gets cleared out.

Update: It appears to happen because when the initial empty data array comes in, it tries to build the columns off of it and creates a promise. But on the second go-around it skips that attempt and thus there's no promise, which probably resolves instantaneously with $q.all(). Meanwhile buildColumns() promise gets resolved and its callback, with the empty data set, blows away the rows.

c0bra avatar Nov 13 '14 19:11 c0bra

Still happening. If I do a ctrl-F5, the header columns get set to only a few pixels in height, whereas if I just navigate to the page, they work fine.

Only happens when I include a column using cellTemplate.

joshmackey avatar Nov 14 '14 20:11 joshmackey

@joshmackey If you're having issues with the inline template, I've fixed this in the past by wrapping the whole template in a <div>. For example:

<script type="text/ng-template" id="blah2.html">
    <div class="ui-grid-cell-contents">TEST: {{COL_FIELD CUSTOM_FILTERS}}</div>
</script>

I also looked at your example and changed cellTemplate to blah.html and things seem to work fine.

McShazy avatar Nov 16 '14 01:11 McShazy

This was due to a different issue. #2110 caused it.

When I removed the offending styles, it all worked.

joshmackey avatar Nov 16 '14 02:11 joshmackey

I am also facing this issue. I wanted auto-focus on the input element on click of filter button(external filter). So I explicitly defined the headerCellTemplate in columnDefs. I am keeping the html code in a separate template and I am trying to reference the in columnDefs. In the console it says fetching URL and does not actually apply the template in the header.

prathik457 avatar Oct 03 '16 18:10 prathik457