Dynamically set column widths after every draw

Dynamically set column widths after every draw

tableguytableguy Posts: 5Questions: 3Answers: 0
edited April 2017 in Free community support

I am using servserside processing to load pages of data at a time. As the pages change and data of new character lengths is loaded into the grid, the column widths re-adjust which creates a constant readjustment of the column/table width.

I don't want to set arbitrary widths since I will never know what columns it will contain. Therefore, I need some way to retain the maximum width that each column has ever been adjusted to and then, after a draw, iterate back over all the columns to set them to that max width.

The end result would be a grid where the columns increase in size, but never decrease.

Imagine something like this:

//this initializes all the column (probably
//don't even need this first loop)
var colwidths = new Array();
for (var i in datatable.columns) {
    colwidths.push(datatable.columns[i].width);
}

//after every table draw, iterate over columns
//and set each column to the max width it has
//every been adjusted to:
for (var i in datatable.columns) {
    if (datatable.columns[i].width > colwidths[i]) {
        colwidths[i] = datatable.columns[i].width;      
    } else {
        datatable.columns[i].width = colwidths[i];
    }   
}
This discussion has been closed.