Is there way to set detailRowHeight prop to 100% in ag-grid? - ag-grid

Recently started working on a master detail structure angular ag-grid. The structure has two levels of master-detail nesting. I need to fix the heights of inner - 2 grids such that they occupy all available real estate on the screen. Currently, ag-grid defaults it to 300 px and a lot of whitespace or unused space appears on a 1920x1200 screen resolution monitor. I also need to have fixed headers for all grids.
Any ideas or pointers would be appreciated...
Update: Referring to a forked version of plunker example from ag-grid here - https://next.plnkr.co/edit/yUzo4EqONEmgCmIw This is simple and basic set up for master-detail grid.
Note that: I haven't set any detail row height and have setup just one record to show up in the grid to test for the issue.
If you run the plunker code and view the result in separate window, notice that the inner / child grid doesn't occupy all the space available below it. In other words, it doesn't take as much as space/height available from parent container (master's detail row). The default 300px master detailRowHeight is making height fixed for inner grid. Also, from documentation, detailRowHeight prop doesn't seem to take something similar as 100% or 100vh and only takes fixed pixels number. Added a picture of the example below and the height / unused space I referred
We have different resolutions that users use to view data in grid and the heights of inner grids need to auto-adjust taking max. available space to show most information in the grids.

You could try something like this, I pulled it from the documentation:
In your component.ts file add this method. If it's a detail row it will apply different calculations than the other rows.
public rowHeight(params) {
if (params.node && params.node.detail) {
var offset = 80;
var allDetailRowHeight = params.data.callRecords.length * 28;
return allDetailRowHeight + offset;
} else {
// otherwise return fixed master row height
return 25;
}
};
In your template add the following: [getRowHeight]="rowHeight"
<ag-grid-angular
#agGrid
style="width: 100%; height: 100%;"
id="myGrid"
class="ag-theme-balham"
[columnDefs]="columnDefs"
[masterDetail]="true"
[detailCellRendererParams]="detailCellRendererParams"
[getRowHeight]="rowHeight"
[rowData]="rowData"
(gridReady)="onGridReady($event)"
></ag-grid-angular>
Hopefully this will get you moving forward. Good Luck!
https://www.ag-grid.com/javascript-grid-master-detail/#detail-row-height

So I don't have a great, full solution for you but as a starting point I would use CSS to override the styles ag-grid is setting - I don't think detailRowHeight is going to help.
Here's my plunk getting close to what you want with some simple CSS I put in index.html. You can use !important to override ag-grid styles, or you could use javascript to set the CSS after ag-grid does. I prefer !important in this case and don't have to worry about timing.
https://next.plnkr.co/edit/mmXBBJE5Wa1JrX7v
The problem I wasn't going to get into is getting it to dynamically fill up available space, depending on the row selected, scroll position, etc. I can't think of any simple way to achieve that - I do this type of thing in grid often and end up writing javascript to calculate the available space, and then set the CSS in javascript.

In ag-grid you have the possibility to set auto height for details.
Set grid property detailRowAutoHeight=true to have the detail grid to dynamically change it's height to fit it's rows.
const gridOptions = {
// dynamically set row height for all detail grids
detailRowAutoHeight: true,
// other grid options ...
}
However if you are providing your own detail component...
detailCellRenderer: 'MyOwnDetailsComponent',
then, it might not work and you will still need to provide an grid options height detail content through...
detailRowHeight: 560,
Please see the ag-grid documentation here

Related

How can I make the grid cells show the whole input text in ag-grid?

I hope you're having a good day.
So I am using ag-grid in my project to transform a bunch of excel tools(files) in one unified web-application.
So far so good.
However, I couldn't find a way to make the grid cells show the whole input text with the ag-grid framework.
In Excel:
In ag-grid:
I hope I have made my point clear.
I have searched in the ag-grid documentation but with no result. This also seems to be the default input text cell rendering in all of their projects examples.
https://www.ag-grid.com/javascript-grid-cell-editing/
Any help is welcome :)
This one is similar to one I already answered: AG-Grid - How to increase row height dynamically?
Provide a CSS class for the column
{
header: 'Address',
field: 'address',
cellClass: "cell-wrap-text",
}
CSS class - keep it in your root level styles.
.cell-wrap-text {
white-space: normal !important;
}

Change default CSS class of Table component on SAPUI

I'm using sap.m.Table component. I'v noticed that my cells have default css class sapMListTblCell nd hegight of rows look me very large:
I want height of rows is more adjusted to cell's content.
I've seen this example. In it cells have another css class: sapUiTableTd
I want my cells of my table have that css class. I think I should change css class of my table to sapUiTableCnt (like the example). But it doesn't work.
Please, someone could tell me What I should do?
The cells have that height because UI5 is mobile first - controls are optimized for working on mobile phones. The spacing / size of various controls depends on a so called content density. Normally, you should check whether or not the user is using a mobile device and set the corresponding content density to your root view. By convention, this check is done inside the Component and then called by the root view's controller.
So, setting a compact density class would most likely solve your problem. You can also create your own density class specifically for tables (and other controls that you may want to target). You can set the compact density and specify e.g. the height of the cells:
CSS style:
.sapUiSizeCompact.myCustomSize .sapMListTblCell {
height: 1rem
}
View:
<Table class="sapUiSizeCompact myCustomSize" />
You can find a working version here (comparison between cozy, compact and our custom density class): https://jsfiddle.net/z2gkvde0/1/.

gadgets.window.adjustHeight() calculates height of the gadget incorrectly

I am writing an opensocial gadget. My structure is something like this:
<div style="height:200px;overflow:auto;">
<div id="dComment">Comments are loaded here.</div>
</div>
I update the content of the "dComment" every second, and its content gets some scrolling.
In my gadget I have specified <Require feature="dynamic-height"/>
When I use gadgets.windows.adjustHeight() it calculates the height of the content regardless that I have made some part of it hidden through adjusting a height for my outer div. As a result I see a huge white space below my content !!!
I know that I can specify height for adjustHeight function. But then it means that on every update I have to calculate the height of the gadget myself, and I don't want to do it (if possible).
Can someone explain to me why it happens and how can I solve it ?
Instead of visibility:hidden use display:none

How to have the container adjust to a GWT grid?

I have a DataGrid with a SimplePager and when theres less than the predefined number of rows per page (in this case 15) the container will show those rows and leave a white space in between the grid and the simplePager (where the other rows would be).
I have seen some mentions on other sites about rendering datagrid first and then fit it into the container, but i have no idea what this means (Or at least, i don't think they're saying its as easy as removing it from the parent and re-attaching it, since i've tried that already).
Thanks in advance.
My proposition - resize container after data fetch, after rendering of grid. It will be just something like this:
container.setHeight(grid.getOffsetHeight() + "px");

gwt 2.4 DataGrid - auto set column width?

I have a problem with DataGrid in gwt 2.4. I made table with CellTable, and everything worked fine. But I needed fixed header, and then just replaced CellTable with DataGrid. I had problem with .css file, but than has been resolved.
Now, the problem is that every column have fixed width, and table put every row just in visible part of screen.
This is new and old screen shots, to make things more clear :)
http://img832.imageshack.us/img832/5026/oldscreenshot.jpg
http://img834.imageshack.us/img834/1489/newscreenshot.jpg
Can someone help to make old looking, but with fixed header.
You can set a fixed width for each column of the data grid:
dataGrid.setColumnWidth(sampleColumn, 40, Unit.PX);
and expand the total data grid width:
dataGrid.setWidth("100%"); // choose the most useful in your app
dataGrid.setWidth("1400px");
I'm not sure what the right answer is, but I don't think the previous responders understood the question.
Basically, you want dataGrid to use "table-layout: auto" instead of "fixed". This is what cellTable does. Table columns are auto-sized based on content.
This is easy for the content table, but to get the header-freeze, dataGrid is using a separate div/table for the header. Therefore, the header table's columns need to be explicitly sized based on the data table. They also need to be resized anytime the table changes (browser resizes, etc.). I plan on adding resizeable cols on a dataGrid, so I'll be hitting this same challenge soon I expect and will update when I have something more explicit if anyone is still tracking this thread...
need to wrap your content in your td with an inner div. and make sure the overflow-x is set to hidden.
table {
overflow: hidden;
white-space: nowrap;
table-layout: fixed;
}
td div{
overflow-x:hidden;
}