Having trouble getting help?
Contact Support
Contact Support
Set the disabled state in Vue Radio button component
11 Jun 20243 minutes to read
RadioButton component can be enabled/disabled by giving disabled
property. To disable RadioButton component, the disabled
property can be set as true
.
The following example illustrates how to disable a radio button and the selected one is displayed using change
event.
<template>
<ul>
<li>
<div id="text">Selected: Option 1</div>
</li>
<li> <ejs-radiobutton label="Option 1" name="default" checked="true" :change="onChange"></ejs-radiobutton></li>
<li> <ejs-radiobutton label="Option 2" name="default" disabled="true" :change="onChange"></ejs-radiobutton></li>
<li> <ejs-radiobutton label="Option 3" name="default" :change="onChange"></ejs-radiobutton></li>
</ul>
</template>
<script setup>
import { RadioButtonComponent as EjsRadiobutton } from '@syncfusion/ej2-vue-buttons';
import { enableRipple } from '@syncfusion/ej2-base';
enableRipple(true);
const onChange = function (args) {
document.getElementById('text').innerText = 'Selected : ' + args.event.target.ej2_instances[0].label;
}
</script>
<style>
@import '../node_modules/@syncfusion/ej2-base/styles/material.css';
@import '../node_modules/@syncfusion/ej2-buttons/styles/material.css';
;
.e-radio-wrapper {
margin-top: 18px;
}
li {
list-style: none;
}
#text {
font-size: 16px;
}
</style>
<template>
<ul>
<li><div id="text">Selected: Option 1</div></li>
<li> <ejs-radiobutton label="Option 1" name="default" checked="true" :change="onChange" ></ejs-radiobutton></li>
<li> <ejs-radiobutton label="Option 2" name="default" disabled="true" :change="onChange"></ejs-radiobutton></li>
<li> <ejs-radiobutton label="Option 3" name="default" :change="onChange"></ejs-radiobutton></li>
</ul>
</template>
<script>
import { RadioButtonComponent } from '@syncfusion/ej2-vue-buttons';
import { enableRipple } from '@syncfusion/ej2-base';
enableRipple(true);
export default {
name: "App",
components: {
"ejs-radiobutton":RadioButtonComponent
},
methods: {
onChange: function(args) {
document.getElementById('text').innerText = 'Selected : ' + args.event.target.ej2_instances[0].label;
}
}
};
</script>
<style>
@import '../node_modules/@syncfusion/ej2-base/styles/material.css';
@import '../node_modules/@syncfusion/ej2-buttons/styles/material.css';;
.e-radio-wrapper {
margin-top: 18px;
}
li {
list-style: none;
}
#text {
font-size: 16px;
}
</style>