B4J Question [BANanoVuetifyAD] How to set myswitch1 Yes or No,Because I want to bring the value to switch,I don’t know how to set the following

joulongleu

Active Member
Licensed User
Longtime User
code:
Dim r2c1 As String = vswitchs.MatrixID(2, 1)
Dim myswitch1 As VueElement = vuetify.AddSwitch(Me, r2c1, "myswitch1", "myswitch2", "Open OR Close", "Yes", "No", "green", False, CreateMap(":loading":True))
switches.BindVueElement(myswitch1)
 

Mashiane

Expert
Licensed User
Longtime User
Hi

The value of the switch or any element with vuetify for example is bound to the v-model. So when this switch was created the v-model specified is "myswitch2". What we need to change is that value.

As you can set any true-value and false-value, for this example, when the switch is true, we want it to return "Yes" and when its false we want it to return "No".

If we wanted, we could have said true-value=True and false-value=False. This is a flexibility that ensures that even if we say.

true-value="Smile", false-value="Sad", we are able to return whatever we want.


So if true-value="Yes" therefore to make the switch true, execute

B4X:
switches.Setdata("myswitch2", "Yes")

So if false-value="No" therefor to make the switch false, execute

B4X:
switches.Setdata("myswitch2", "No")

Thus you update the v-model of the switch to match the true-value or false-value you want.

Ta!

BTW, this also applies to the checkbox.

To get the value of the checkbox...

B4X:
Dim cvalue as string = switches.getdata("myswitch2")
 
Upvote 0
Top