Angular UI Grid change orientation to horizontal? - angular-ui-grid

I am not sure if I need to change the grid templates or if there is a regular way:
I want a horizontal grid with 20 items.
The grid dont need horizontal scrollig because the pagination is below.
Each item should have the same fix size.
Each item should have a top down order (and not left to right).
Its my first time with ui grid and I tried a bit but the result is "crap" :/ An working example will be so nice :)

Related

Is there a way to auto-scroll horizontally in a Vaadin Grid?

Currently using Vaadin 23 and was wondering if it was possible to use scroll horizontally within a Grid programmatically, much like some of the built-in functionality with scrolling to the top or bottom row. However, in this case I would like to scroll using a column as reference (while maintaining the current vertical scroll position).
One idea would be to put a component into the column header, and then scroll to that component. Something like:
Grid.Column<SamplePerson> emailColumn = grid.addColumn("email");
Span emailHeaderText = new Span("Email");
emailColumn.setHeader(emailHeaderText);
Button scrollToEmail = new Button("Scroll", e ->
emailHeaderText.scrollIntoView()
);
It doesn't work perfectly, as the header component does not cover the whole column width, but it might be good enough.

Vaadin 14 grid initial row height is incorrect and rows overlap

I am using Vaadin Flow 14.6.2, the material theme, and custom CSS styling in my application. When loading a grid that has a cell that has content that wraps 5 times, when the grid initially loads the grid rows overlap, truncating the information in the cell that contains wrapped data. Looking at the CSS this is due to CSS "transform: translateY(#px)" setting that is too small onto the Grid's TR (row) tags. As a point of reference, the grid places a translateY of 76 pixels on the second row.
Screen shot of grid with overlapping rows
Selecting a row in the table or resizing the browser will cause the grid to refresh and the translationY value will be recalculated, increasing the translateY value to 118 pixels, and the grid will display all rows with the appropriate spacing.
Screen shot of grid after selecting a row
Is this a defect in the grid where the row offsets are not initially calculated to the correct height?
I am not sure how to debug this further or if there are any workarounds to trigger the grid to recalculate row sizes so that it may display correctly from the start. I tried programmatically selecting the first row and the result was that the first row displayed correctly but subsequent rows were truncated.
I'd try adding a Div element inside the cell using a ComponentRenderer, and put the white-space: normal and word-break: break-word on that element. Since the grid supports adding components of any size, and should adjust row height according to the heighest component, this may trigger initial calculation.
I was able to work around this issue by changing how this page is navigated to. A change was made to a parent view to trigger navigation using an anchor instead of a button. With an anchor a new UI is created and then the grid is added to it, but with the button the existing UI is reused. There is something in the display of the grid on a new UI or something related to the difference in navigation that triggers this problem. Reverting back to using a button is a superior solution as it solves this problem and does not trigger creation of a new UI.

Vaadin chart not using up correct width

In Vaadin 14.6.1, I have created a horizontal layout with 2 charts (and some other stuff). The charts are not using up the correct width -- they seem to not "pick up" on the right width (see screenshot below). I set the width to 100% etc. Also, this problem disappears if I use a simpler component, such as label, instead of charts (from Highcharts). I've experienced a similar problem before, but in more complex settings (e.g. a user adjusts the splitlayout and the underlying chart does not resize). But in this case, it's an even more reasonably straightforward scenario (i.e. no adjustment by user of the width of any layout) and yet Vaadin doesn't seem to pick up the right width, at least when using charts. Is this a known or reproducible issue? If so, any workaround?
Charts indeed behave badly with some layouts. I have noticed two cases. The other is the Board component, where the workaround is just simply wrap Chart inside Div, i.e.
Div div = new Div();
div.add(chart);
// and then add div to Board
SplitLayout is more tricky. You need to call Chart to reflow after splitter has been moved. Something like the following finds all the charts and forces them to redraw.
splitLayout.addSplitterDragendListener(event -> {
getUI().ifPresent(ui -> ui.getPage().executeJs(
"Array.from(window.document.getElementsByTagName('vaadin-chart')).forEach( el => el.__reflow());"));
});
Note, if you have only one chart or have conveniently the references to chart instances you can do
chart.getElement().executeJs("$0.__reflow();", chart.getElement());

What will be the best UI component to render array items horizontally

I have an array of 'n' number of items. I am displaying them in a horizontal stack view, having fixed width of the superview.
Issue is, when the number of items are more, then the horizontal stack view is not displaying all of them.
I need to display all the items of an array in some UI placeholder horizontally with some decent amount of spacing in between. If the items are more they should come in the next line.
Will horizontal stack view be suitable for my requirement ? If not, then which UI component should I use? Example will be appreciated.
Adding to the answer of #DrMickeyLauer, If you want to make your UI look better with some eye catching animation while viewing the items then go for iCarousal.
Take a look at this URL for the sample implementation https://github.com/nicklockwood/iCarousel
UICollectionView is exactly what you're after. Use it with the standard UICollectionViewFlowLayout in horizontal mode.
It will then display all its elements filling "lines" from top to bottom, thus achieving a grid layout, which seems like what you want.

Smooth scroll string grid

I need a string grid which can scroll smoothly, as opposed to locking in the top row / left col positions. When you scroll a TStringGrid, the left visible column and top visible row snap into position along the top/left edges. I need the ability for the user to scroll smoothly, not locking these edges into place.
I wouldn't think this is possible to modify in the VCL TStringGrid (or TCustomGrid for that matter) because it relies on properties such as TopRow, LeftCol, VisibleRowCount, etc.. I'm pretty sure I'll need a third party control, but I'd love to use the TStringGrid if possible, because I already have a lot of code wrapped around it. If I do need a third-party grid, then I'm hoping it works closely enough like the TStringGrid.
The short answer is no, you canĀ“t pixel scroll a TStringGrid. You can simulate a grid using a TScrollBox. You can put a grid inside the TScrollBox, make the grid large enough to fit all rows and cols, and turn off its scroll bars, but some things like keyboard navigation will not work.
Other alternative is to use the TVirtualTree in grid mode or TListView. Both have this pixel scroll you want.
I was looking for something similar. Unfortunately, you can't do it with Borland's code but Lazarus can do it
Scrolling the TStringGrid pixel by pixel
You may want to take a look in their code.

Resources