Consistent grid headers with Flexigrid ?

前端 未结 12 1048
长发绾君心
长发绾君心 2021-02-03 10:05

So I\'m trying to use the flexigrid plugin. It looks like it\'s going to work great aside from the fact that it looks like you have to manually set the column widths. Otherwis

12条回答
  •  死守一世寂寞
    2021-02-03 10:43

    From your own answer, I added setting min-width so that the columns don't get squeezed differently if the flexigrid width was set too narrow or the flexigrid resized, tested only in chrome:

        $(this).width(realWidth);
        cells.eq(i).width(realWidth);
        // these two lines added
        $(this).css('min-width', realWidth);
        cells.eq(i).css('min-width',realWidth);
    

    Just doing this break column resizing, as that modifies the width of the div inside the th and td, but that can be fixed with a few additional lines in flexigrid in the "dragEnd" function:

    . . .
    // LINE 211
    $('th:visible div:eq(' + n + ')', this.hDiv).css('width', nw);
    // ADD THIS AFTER LINE 211
    $('th:visible div:eq(' + n + ')', this.hDiv).parent().css('min-width', nw);
    $('th:visible div:eq(' + n + ')', this.hDiv).parent().css('width', nw);
    . . .
    // LINE 214
    $('td:visible div:eq(' + n + ')', this).css('width', nw);
    // ADD THIS AFTER LINE 214
    $('td:visible div:eq(' + n + ')', this).parent().css('width', nw);
    $('td:visible div:eq(' + n + ')', this).parent().css('min-width', nw);
    

提交回复
热议问题