Knockout-Contrib / KoGrid

A Knockout DataGrid
https://knockout-contrib.github.io/KoGrid/
280 stars 131 forks source link

Columns overlap in 2.1.1 when loading data over JSON #203

Open onethread opened 11 years ago

onethread commented 11 years ago

I've been trying to load JSON data through AJAX, and the data would load, but all the columns in the grid would overlap each other. After much fiddling of the existing examples on plunker: http://embed.plnkr.co/usa2JIgkviFSOdsvqq8E/preview

Toggling between the previous version here: http://ericmbarnard.github.com/KoGrid/lib/KoGrid.debug.js and 2.1.1 causes the error to manifest. Sorry for hot linking right to the raw, couldn't figure out where else to find the link.

Bug occurs in FF 10 and the latest Chrome.

ImaginaryDevelopment commented 11 years ago

try something like this in the first ajax load success after you load the data:

  //fix for kogrid FAIL when first initialized hidden
    var initializedgrid = false;
    self.isInboxVisible.subscribe(function (newValue) {
        if (newValue === true && !initializedgrid) {
            initializedgrid = true;
            ko.contextFor($('.koGrid').first().children()[0]).$data.init();
        }

    });

probably just the line

ko.contextFor($('.koGrid').first().children()[0]).$data.init();

ImaginaryDevelopment commented 11 years ago

likely duplicate of https://github.com/Knockout-Contrib/KoGrid/issues/183