CraigCav / Knockout-jqGridBinding

A grid binding plugin for Knockout.js that provides basic integration with the JqGrid plugin for jQuery.
MIT License
37 stars 10 forks source link

Width is always 99 % #8

Open iamandycohen opened 11 years ago

iamandycohen commented 11 years ago

in the $.fn.tabletogrid function, element is set to $(this).width('99%') and then later on the width is set to element.width() which has been previously set by the plugin. this needs to be changed to:

$.fn.tabletogrid = function (settings, bindingContext) {
    settings = settings || {};
    $(this).each(function () {
        if (this.grid) { return; }
        var element = $(this)/*.width('99%')*/,
            options = { datatype: 'local', colModel: [], colNames: [], height: 'auto', altRows: true },
            pagerOptions = settings.pager || { target: '#pager', rowNum: 10, rowList: [10, 20, 50] },
            idParamName = settings.rowid || 'id';

        pagerOptions.pager = $(pagerOptions.target).length == 0 ? null : pagerOptions.target;
        $.extend(options, pagerOptions, { width: element.width(), caption: $('caption', element).text(), localReader: { id: idParamName} });

        buildColModel(element, options, bindingContext);
        element.empty().jqGrid(options);
    });
};