Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
15
Row Virtualization not working with igGrid when the column width is * (i.e. Auto width)
posted

Hi,

I am trying to achieve row virtualization in igGrid. I want to auto scroll igGrid and select the row programmatically as per needs. Seems like the  rowVirtualization only works if the width of the column is set in px or percentage and not asterisk (*). 

Is there any way to scroll grid to the correct row on any page in the grid and keep the width as * so that the content can be shown properly?

Parents
No Data
Reply
  • 1700
    Offline posted

    Hello Dipesh,

    The rowVirtualization feature in the Infragistics IgniteUI for jQuery igGrid indeed has limitations regarding column width when using the asterisk (*) configuration. However, you can work around this to achieve the desired functionality.

    Instead of using the *, calculate the available width dynamically in JavaScript and set the column widths programmatically. This provides the illusion of proportional sizing while meeting the requirements of rowVirtualization. This code should be called on load and on resize.

    function adjustColumnWidths() {
            var gridWidth = $("#grid").width(); 
            var columns = $("#grid").igGrid("option", "columns"); 
            var columnCount = columns.length; 
            var columnWidth = Math.floor(gridWidth / columnCount); 
    
            for (var i = 0; i < columns.length; i++) {
                columns[i].width = columnWidth + "px"; 
            }
    
            $("#grid").igGrid("option", "columns", columns);
            $("#grid").igGrid("dataBind"); 
        }

    To scroll to specific row you can use the following code where the rowIndex represents the index of the row you would like to scroll to:

    $("#grid").igGrid("scrollTo", rowIndex);

    Please let me know if you need any further assistance

    Regards,
    Ivan Kitanov

Children
No Data