Set a property back to "NotSet" - asp.net

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;

Related

Google Appmaker selectedRow

On a Google appmaker table, I have a label that I only want visible when the row is active/selected by the user.
I can see that the datasource.itemtIndex would give me the current index that my label is at (I presume it's not the selected index), but I can not seem to find a property that shows me the currently selected index/row.
Bind the visibility of the label like this ==>
#widget.datasource.item._key === #datasources.<DatasourceName>.item._key
Just make sure to change <DatasourceName> with whatever datasource you're using.
Try adding this style
visibleOnAncestorHover
to the label styles. This should make it visible both on hover and when selected. (This is used by default on Table widget's row delete buttons, I think.)
EDIT: and remember to have the 'visible' setting on for the label.
The only way I found to do this is to set the visible binding on your label, of course you would want to set your visibility type to absent (will mis-align your table rows to labels) or hidden (will just hide the label). This solution is different from the 'visibleOnAncestorHover' as the label will still be hidden on other rows when you hover on those rows, it is only visible when the row is actually selected. The only binding that seems to work is this:
#datasources.YourDatasource.itemIndex === #widget.parent.childIndex
The following apparently does NOT work:
#datasource.itemIndex === #widget.parent.childIndex
or
#widget.datasource.itemIndex === #widget.parent.childIndex
Please see the picture below:
You can specify this in the style editor:
.app-NewPage-Table1Row:not(.selected) .app-NewPage-Field2 {
visibility: hidden;
}

Stop Invisible Label from taking up space

Is there a way to stop a label control that is not visible from taking up space on a form?
server side:
label.Attributes["style"] = "display:none";
or
label.Visible = false;
or, client-side (css):
#label-id { display: none; }
Set it's visibility to hidden through CSS. Or set it through the code behind to false. From the code behind a false setting should cause it to not be rendered at all.
Optionally, replace the label with a literal control and only emit something to it when you need to.
2 good answers already, so just a couple of notes:
Using Visible=false at the server-side is usually better since that will not output any HTML at all, as opposed to CSS which will output it but just hide it. Unless of course you need it there so you can unhide client-side.
The label itself usually doesn't add any space, it is the white-space before/after it that might, so yet another option (if you work in HTML source view 99% of the time like I do) is to remove any white-space before/after the control. Not as robust as the other options since it could be easy to get that white-space back by mistake (especially if the IDE does it for you while working in design view). Just thought I'd mention it, since this can be good to know if you want the label VISIBLE but don't want the "extra space".

Unset the explicit height value of a flex component?

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.

Flex: Hide (or Remove) Label Text without Changing the Button Size

I have a button with variable-length of label text. I have a User Setting that can turn on or off the label text on this button.
How can I implement this?
NOTE: the button's background has a gradient color.
I tried using BlendMode.LAYER, no luck;
I tried using Button.resizeHandler
private function resizeHandler(event:ResizeEvent):void
{
if (event.oldWidth > this.width)
this.width = event.oldWidth;
if (event.oldHeight > this.height)
this.height = event.oldHeight;
}
but it only worked if the initial UserSetting value is true.
How about embedded font? I don't know how to apply it to button
You can use the property minWidth and maxWidth. minWidth to specify the minimum width that the button should have. and maxWidth to specify the maximum width the button can have.
You can extend mx.controls.Button to add a show/hide label function. The text field is a protected property so you can just set the visibility on/off in your function. Leave Flex to measure everything correctly itself.
If you want to grow/shrink the button when the text is on or off, you can also set the button width. You will have to calculate the width based on the textfield width.
What happens if you just set the button's width? That way, it should be a constant width no matter what you set as the label.
Most likely width is being calculated in the updateDisplayList method. So, code in your resize handler may be being reset at the next render event.

Dojo DataGrid - preventing column resize

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/

Resources