Search code examples
footable

Iterating all rows and changing a specific value ends up in a disappearing table


I have following problem: I have a small application running where i have implementes a language switching function. Therefore i need to change the datetime columns in footable for the right date format. My idea was to iterate through all rows, get the date value, recalculate it in the right format and write it back to the table. But This approach is not working properly, when i try it, you can see the very first row changing, and then the whole table disappears. I have attached some screen shots and the relevant code to explain the problem...

My Code (for iterating the rows and changing the value):

var ft = FooTable.get("#spiele_data");
$.each(ft.rows.all, function(i, row){
        v=row.val();
                var m = moment(v.sp_timestamp, 'L LT');
                    v.sp_timestamp=m.format('L LT');
        row.val(v);
    });

This is what happens:

Table is loaded and displayes properly Table is loaded and displayes properly

After changing the language => see the first line After changing the language => see the first line

Immediatley after that the table is gone Immediatley after that the table is gone

What am i doing wrong or is there a better possibility to change specific columns in all rows?

Best regards Christian

+EDIT: One more thing: the $.each-loop is iterated completely. I've tested that by writing the index to the console.


Solution

  •  $('table').trigger('footable_redraw');
    

    You need to call redraw to see footable again