stackfull / angular-virtual-scroll

Source for the sf.virtualScroll module for AngularJS
MIT License
262 stars 42 forks source link

"Unable to compute height of row" - What to do? #31

Closed OClement closed 10 years ago

OClement commented 10 years ago

Hi, I'm trying to use AVS in a context I think should work, but for some reason doesn't.

More specifically, I am building a directive that generates a table. The directive's template currently uses an ng-repeat for the tr (using tack by, I think you don't support this yet? Or is it not needed with AVS?)

Here's a simplified markup of the directive's template:

<div class='treegrid'>
    <div class='viewport virtual'>
        <table class='table table-striped'>
            <thead> .... </thead>
            <tbody>
                <tr sf-virtual-repeat='row in rows'>
                    <td ng-repeat='col in colDefs track by col.field'>{{....}}</td>
                </tr>
            <tbody>
        </table>
    </div>
</div>

I am thinking I get the error (in title) because of order of operation/directive priority or something like this. Data is loaded asynchronously.

Is there a way to make this work in that scenario?

Thanks

stackfull commented 10 years ago

If you use CSS to set an explicit height (e.g. height: 20px) on the tr, it should work.

OClement commented 10 years ago

Haaaaa yeah makes sense, it does :P Should have thought about that one... thanks!

stackfull commented 10 years ago

no prob. It's a shame I couldn't delay the calc until the height has settled - but angular just doesn't work that way

OClement commented 10 years ago

Yeah I am not sure if there’d be a way either Maybe using multiple priorities like ng-repeat does would be a start (I haven’t looked at your code or blog post about this yet)

Despite the fact that I’ve been using Angular for the last 2 years I’m still not too sure about how Angular’s Directive’s more advanced concepts, like how transclusion plays out along with compile/pre/post functions and priority and all that. I guess I’ll have to sit down one day and read just about this and experiment…