I have a collection view showing a simple one-column list with a NSCollectionViewCompositionalLayout. The cells take the full width and have a fixed height.
I would like that, upon an external event, one of the cell grows in height (animated).
That could be for example :
when the cell is selected
when an image shown in the cell is downloaded
I found no way to do this in Apple's doc, when I think this is a fairly common use case. It seems that NSCollectionViewCompositionalLayout is very flexible in positioning cells, but very static. All cell sizes are computed once and for all.
Is there any API for this ? What's the way ?
I'm creating a pivot table using jqgrid with group headers. I do some calculation on input data to figure out if combined column width would exceed the fixed width of grid. If it does not exceed then i would change shrinkToFit : truefor grid to occupy full width. If I do it, then dragging column width creates alignment issues between header and body.
Problem gets worse if frozen column are enabled. The fixed header div wont expand like the column underneath it if shrinkToFit is enabled.
Here is a demo to understand the problem : http://codepen.io/anon/pen/NbxWrQ
Any leads will be helpful.
Thanks in advance.
I'm about to test a website with Selenium. There is implemented a table with SlickGrid.
I have the Problem that when I read in a row i get only 29 columns but there were about 40 (in real).. This cause to 100% to the virtualised scrolling.
I'm wondering, what's the default amount of columns which appears in the dom?
It took me a while to resolve how it's done and I can say it's a bit tricky. There is no such thing as a "default amount" of columns, this amount is getting computed, see below for a bit of technical details.
You can check the slick.grid.js files line 1787. There is a function cleanUpAndRenderCells(). This is responsible for calculating and rendering the cells which aren't on the grids canvas. For example when you scroll the horizontal scrollbar, this function gets called and based on the direction of the scroll they check if the next set of cells aren't on canvas and can fit the canvas, they append the cells to the DOM.
For the matter of reading the row values
I see two possible ways of doing that using javascript.
If you are using a data array as datasource:
data[grid.getSelectedRows()[0]]
If you are using a DataView as datasource:
grid.DataView.getItemById(0)
Both will return an Object with property names of columns.
However I'm not sure how/why would you integration test this, the slickgrid package is already tested, you can check it here.
I need to set a different row height for a few items in my grid but it seems to break the layout when I do. Is there a way to do this with slickGrid?
SlickGrid doesn't support variable height rows.
If you're looking for a library similar to SlickGrid, but with variable row height support you may want to consider giving DobyGrid a try: https://github.com/globexdesigns/doby-grid
I want slickgrid to autosize the columns based on the widest content or header text - whichever is wider. In simpler terms, I want it to simulate the default behavior of regular HTML tables when it comes to column sizing. How can I do it in slickgrid?
When constructing your options, you can use forceFitColumns: true
var options = {
enableCellNavigation: true,
forceFitColumns: true
};
This will make the columns fill the entire width of your grid div.
The OP is looking for columns to grow to match their content. grid.autosizeColumns() grows the cells to fit the parent container, which is not the same thing.
I have added this feature, and it is about as manual as you might imagine. You loop through the displayed cells and measure each one, saving the widest cell and using that width to set the width of your column. SlickGrid gives you good access to the cells in the viewport, so that works nicely.
The measurement algorithm is your big decision. You may put the content off screen and measure it, as #jay suggests. This works, but it is the slowest method, as it requires a repaint to insert, and a repaint when you remove. There may be ways to optimize. The solution I went with is to measure the width of every letter in the alphabet, as well as other typographic characters we come across, and sum them to generate a width. Yes, this sounds absurd. It has many constraints: The font size must be the same, it doesn't support images, there can't be any line returns, and more. If you can live with the constraints though, you can calculate sizes for a huge grid viewport in <5ms, because the character widths are only measured once.
After you get the sizes of the columns, you assign them to your columns using grid.setColumns().
Slickgrid will not support column auto size based on data.You need to write a plugin or fork the slickgrid core to modify.
Here is the link I have created a plugin to handle slickgrid auto size
https://github.com/naresh-n/slickgrid-column-data-autosize
I added this after the grid is drawn and it works fine.
$(window).resize(function() {
var cols = grid.getColumns();
grid.setColumns(cols);
})
You should be able to call the autosizeColumns() method of the grid object.
grid.autosizeColumns();
Make this simple adjustment to Naresh's https://github.com/naresh-n/slickgrid-column-data-autosize, on the init function:
Add $container.ready(resizeAllColumns); to the init function.
This ensures the columns autoresize on initial load
Insert the text into an off-screen element and retrieve the width of the element. This is what excanvas does to measure text. Use this to set the width of the column since it's expecting a pixel value.