To download NI software, including the products shown below, visit ni.com/downloads.
Note: Deprecated
This example is deprecated and no longer maintained.
WebVIs should instead use the Control Extensions for WebVI example instead which uses a simplified control reference based API.
The example includes VIs to help create custom styles for controls in WebVIs. See the Best Practices for Customizing the Appearance of Controls in a WebVI for information about when to use custom styling in a WebVI. See an example page using the library.
Note: If you use this library to create CSS to customize the appearance of controls, these modifications may not persist from release to release. If you modify the CSS from NI defaults using this library, plan to test your code each time you upgrade to a new version of the G Web Development Software and update or modify this library as necessary.
The library includes a Create Style VI that has two inputs, the rule selector and the rule properties:
The rule selector and rule properties are combined together with the Create Style VI to create a CSS style. For example, I want to select all Data Grid cells that contain the text "fail" and set the background color property to "dark red" and the text color property to "white".
In order to choose a control in the page to apply styles to you have to add a unique class to the control and create a CSS class selector to target the control.
The following shows a Data Grid control as an example with a unique class name added that targets that specific Data Grid:
The following shows the diagram to select the Data Grid using the css selector .my-class-name (Note the dot prefix that was added) and the Data Grid column at index zero and looks for string cells containing the text "fail" case-insensitively and sets the background color to dark red and the text color to white:
The following shows the above example running in the browser:
Release 5 - Add Button - Glyph selector, Url Image Value, and example to customize a Button glyph
Release 4 - Support for G Web Development Software 2021
Release 3 - Fix style behavior when grouping is used in DataGrids
Release 2 - Add DataGrid - String Column selector and Data Grid-specific horizontal scrollbar example
Release 1 - First release
Note: Deprecated
This example is deprecated and no longer maintained.
WebVIs should instead use the Control Extensions for WebVI example instead which uses a simplified control reference based API.
Description-Separate-2
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.