I am completely new to Nativescript, I am trying to add class Name dynamically to a gridlayout on tap.
I am not using Angular 2.
How to access the grid layout element and add class name to the same.
All that you need to do is search for the desired element in the UI tree for example by accessing the parent of the Button
or by setting an id
to the element and using the .getViewById()
method of the root of the Page or the Page itself.
Finally in order to set the css class of that View simply set its className
property, something like this:
export function onChangeCssClassButtonTap(args) {
var button = args.object as Button;
var parentGridLayout = button.parent as StackLayout;
parentGridLayout.className = "myGridCssClassName";
}
Here are some documentation articles that may be useful to you:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With