I want to set a default height for all the rows of my sheet. I apply getDefaultRowDimension method, but when I set a value in a cell, the default height is reset.
Some ideas ?
Related
in a GWT project I have a CSS with
.my_datagrid tr {
height: 26px;
}
and in my client code i do
grid.getElement().setClassName("my_datagrid");
that modify the minimum hight (i know isn't final) of datagrid rows, i would need for some reason to set this property (the TR height value) code way or at least read it...but the tr part make it over my understanding,
i tried with
grid.getElement().getPropertyString("tr height")
or
with
dataGrid.getElement().getStyle().getProperty("tr height")
but doesn't work..I understand that i'm working on the data grid element and not on the row but i need to know (or set) the minimal height BEFORE any row is added.
So..anyone knows how to read from css that value or remove it from css and set directly code way on my data grid?
If you need to tweak the CSS itself, then you have to use the CSSOM to manipulate the stylesheet (independently of where it's applied through matching).
GWT doesn't provide a CSSOM API, so you'll have to use JSNI. Also, beware of cross-browser support.
With a DataGrid widget, you'd better use a custom CellTableBuilder where you can inject inline style="" attributes on each generated row and/or cell.
To set a row height on all rows, you do:
myDataGrid.addStyleName("my_datagrid");
There is no way to set a height of all rows to a specific number other than by using a CSS class, but you can set height of a single row:
myDataGrid.getRowElement(index).getStyle().setHeight(26, Unit.PX);
If you need a height of a row, you can do:
int h = myDataGrid.getRowElement(index).getOffsetHeight();
Note that the actual height of a row may be different from the "style" setting, because text can wrap to have more than one line (unless you prevent it).
I noticed that BorderStlye has an explicit None for "Do not show a Border" and a NotSet, which causes the control to revert to its default or CSS style.
I'd like to set the height of a panel to 0 in some cases, but then be able to return it to whatever height is designated in the style sheet, similar to what can be done with BorderStyle. Can this be done?
You can use Unit.Empty:
myPanel.Height = Unit.Empty;
This will reset the implicit value you set before.
But if you want to hide a Control, there are better ways than setting the height to 0.
myPanel.Visible = false;
When a container component is declared without setting an specific height value, the contaniner's height will be automatically set to a value which makes possible to display all of its content/children without scrolling (when possible).
After the component is initialized with the proper height, I explicitly change the height value of the container.
My question is, after I change the component's height, is it possible to switch back to the original height that was automatically set based on the containers contents? I'm looking for some way to unset the explicit value of the component's height.
One trick that may be useful for you is to set the height to "NaN", which effectively "unsets" the explicit value you set earlier.
Without storing the original height before it was manually changed, I don't believe this is possible.
What you could do is extend whichever base object you're using as a container to add a new property called OriginalHeight (might as well add OriginalWidth while you're there).
Then you would override the set height function to store the original height in your new OriginalHeight property before it gets changed. When you need to set it back, you would just set the container's height = OriginalHeight.
contaniner's height will be
automatically set to a value
This is not quite automatic. A component will always set the height and width of children; but it can never set the height and width of itself. It can only make suggestions (using the measure method by setting the measuredHeight and measuredWidth property). It is up to the parent container whether it wants to use or ignore those measuredHeight / measuredWidth values.
The Flex Framework containers all have code written for calculating height / width / positioning. IF you are using those, it may seem automatic; but it is actually a fairly manual process. You're just using code someone else wrote.
If you explicitly change the height value of the container, how do you do it? Inside the container (this.height = newvalue ) ? Or does the parent somehow change the height (myContainer.height=newValue)?
Beyond that, it depends what the original height value was. It is possible you can use the measuredHeight value, but I wouldn't count on it. Although, if you are specifying absolute height and absolute width then measure will never be run.
Probably Jason's answer about storing the old value is the best one.
Is there a way to set a fixed column size in Dojo DataGrid, and not allow it to be resized by the user? Thanks.
The cells defined within the grid's structure support a boolean noresize property. Setting this to true will disable resizing on that particular cell.
You might want to do something about overriding the default CSS though - it appears to use a rather noticeable cursor when hovering over non-resizable cell boundaries.
You can also set a specific width of a column in the structure using the width property on a particular cell.
Example: http://jsfiddle.net/kfranqueiro/qNfC9/
I want to make editable cells with multi-lines content in QTreeWidget and I use for this purpose QPlainTextEdit as a delegate. I need to set proper size to all rows that switching between editing and displaying went smooth, without any visible changes.
rect = textEdit.blockBoundingRect(textEdit.firstVisibleBlock())
With this I can find out the height I need to set for the row, but I missing the place where I can do it.
How can I set proper height to QTreeWidget's rows on initialization stage and how to handle it's changes?
You need to reimplement delegate's sizeHint(). It will automatically handle row's height and width.
And note, that QTreeWidget::uniformRowHeight property must be false in this case, though it will slow tree element rendering if it contains many rows.