Is variable rowheight a possibility in SlickGrid?

前端 未结 10 908
离开以前
离开以前 2020-12-03 01:22

I would like to provide variable row height depending upon the content size. is it possible in Slickgrid?

Can you point me towards any examples?

10条回答
  •  再見小時候
    2020-12-03 01:54

    Define this variable outside....

    var tableHeight = 0;

    Before creating the slick grid, use below the lines:

    // 30 px for each line this will cover the header... You can adjust this value for your table.

    tableHeight = dataTable.length * 30;    
    
    if(tableHeight >  ($(window).height() - 400)){
           $("#myGrid").height($(window).height() - 400);
    }else{
           $("#myGrid").height(tableHeight);
    }
    

    If user changes the screen when page is already generated, the below will resize the table based on screen and number of rows of data:

        $(window).resize(function() {
    
        // For grid height
        if(tableHeight >  ($(window).height() - 400)){
            $("#myGrid").height($(window).height() - 400);
        }else{
            $("#myGrid").height(tableHeight);
        }
    
        // For grid width
        $("#myGrid").width("100%");
    
        // Resize the grid dynamically. 
        gridName.resizeCanvas();
    });
    

提交回复
热议问题