angular-footable icon indicating copy to clipboard operation
angular-footable copied to clipboard

Should it work with ng-repeat?

Open jamescam22 opened this issue 10 years ago • 6 comments

My table data is populated with ng-repeat and it doesn't work. If I hardcode the data rows, it will work. Not sure if this is a bug, just asking what the intention is.

jamescam22 avatar Dec 28 '15 20:12 jamescam22

The same problem with ng-repeat, i get a wrong $index after sorting event

kurtiev avatar Jan 04 '16 15:01 kurtiev

I think this is a bug, because paging action before ng-repeat.

I use this tricks to fix it, but user will see a blink.

setTimeout(function() {$('#tblOrders').trigger('footable_redraw');}, 1000)

xwendotnet avatar Jan 05 '16 10:01 xwendotnet

Thanks @xwendotnet that worked for me. If you set the timeout interval to 0 it still works and there is no blink.

dionb avatar Mar 02 '16 00:03 dionb

I solved it with a directive:

JS:

.directive('fooRepeatDone', function() {
    return function($scope, element) {
        if ($scope.$last) { // all are rendered
            $('.table').trigger('footable_redraw');
        }
    }
})

HTML:

<tr ng-repeat="post in posts" foo-repeat-done>

AcademyLime avatar Apr 28 '16 19:04 AcademyLime

@xwendotnet +1!

@AcademyLime works perfect BUT it won't work on ajax, had to use xwedontnet solution (or at least in the script i'm working on)

oxxido avatar May 09 '17 13:05 oxxido

@AcademyLime Your directive snippet is very nice! I have added translation support.

.directive('fooRepeatDone', function($interpolate) {
    return function($scope, element) {
        if ($scope.$last) { // all are rendered
            $('.footable').trigger('footable_redraw');
            $('.footable').footable().bind({
                'footable_row_collapsed' : function(e) {
                    //Your code when a row is collapsed
                    // console.log("footable_row_collapsed");
                },
                'footable_row_expanded' : function(e) {
                    //Your code when a row is expanded
                    // console.log('footable_row_expanded');

                    angular.forEach(angular.element('.footable-row-detail-name'), function(value, key){
                        var a = angular.element(value);
                        var t = a[0].innerText;
                        if(t.indexOf('{{') > -1 ){
                            var exp = $interpolate(t);
                            var res = exp($scope);
                            a[0].innerText = res;
                        }
                    });
                },
            });
        }
    }
})

Animion avatar Nov 03 '17 11:11 Animion