Thursday, 29 August 2013

Slickgrid force columns to fit viewport size when enablecolumnorder equals false and resizable equals false?

Slickgrid force columns to fit viewport size when enablecolumnorder equals
false and resizable equals false?

I have created numerous slickgrids, but this is the first one that I am
creating that I need to have the columns not be resizable and reorderable
(draggable). What I really need is for my columns to fit my viewport at
all times but not be resizable/reorderable, and not extend horizontally
during a screen resize (increase or decrease).
I have found that if I put this into the column options. :'
resizable: false
This will stop them from being resized but upon doing this it resizes my
columns on page load to width I specified per column. Which is normally
what I would want, but I have a specific width of 1300px for my viewport.
So, if I set my pixels just right the grid will behave nicely in the
viewport and look great. However, this application that I am working on
requires the ability to minimize or maximize the screen, upon doing so my
columns which are now set to a specific width remain that width and a
horizontal scrollbar appears pushing my columns past the 1300px range.
If I remove forcefitcolumns and the widths then my columns are really tiny
and it just looks terrible.
Example of one of my columns. :
{ id: "Mode", name: "Mode", field: "Mode", width: 125, sortable: true,
formatter: TaskNameFormatter, editor: Slick.Editors.Text, resizable: false
},
Example of my grid options. :
var GridOptions = {
showHeaderRow: true,
showHeaderRow: true,
headerRowHeight: 30,
explicitInitialization: true,
enableCellNavigation: true,
enableTextSelectionOnCells: true,
forceFitColumns: true,
multiColumnSort: true,
topPanelHeight: 25,
autoHeight: true,
enableColumnReorder: false
};
Example of my grid div. :
<div id="slickGrid" class="grid-body" style="min-width: 800px; max-width:
1300px; height: auto;"></div>
And obviously I have the grid resize. :
$(window).resize(function () {
Grid.resizeCanvas();
});
I am just wondering how you handle this situation, basically I need my
columns to fill the viewport horizontally and maintain that size even
during a window resize. Thoughts? Has anyone defeated this issue before?
If I could just figure out how to dynamically keep my columns the
appropriate size for the viewport I could call that again during a window
resize.

No comments:

Post a Comment