All docs
V17.2
24.1
The page you are viewing does not exist in version 24.1.
23.2
The page you are viewing does not exist in version 23.2.
23.1
The page you are viewing does not exist in version 23.1.
22.2
The page you are viewing does not exist in version 22.2.
22.1
The page you are viewing does not exist in version 22.1.
21.2
The page you are viewing does not exist in version 21.2.
21.1
The page you are viewing does not exist in version 21.1.
20.2
The page you are viewing does not exist in version 20.2.
20.1
The page you are viewing does not exist in version 20.1.
19.2
19.1
18.2
18.1
17.2
A newer version of this page is available. Switch to the current version.

jQuery RadioGroup API

The RadioGroup is a widget that contains a set of radio buttons and allows an end user to make a single selection from the set.

import RadioGroup from "devextreme/ui/radio_group"

DevExtreme widgets are integrated with many popular libraries and frameworks. See the Installation section (for JavaScript libraries) or the Prerequisites and Installation section (for ASP.NET MVC framework) to find details on setting up DevExtreme with a particular library or framework.

The following code shows how to create the RadioGroup widget using every supported library and framework. For more details on working with widgets in these libraries and frameworks, see the Widget Basics topic for jQuery, Angular, AngularJS, Knockout or ASP.NET MVC.

jQuery
JavaScript
HTML
var radioGroupItems = [
    { text: "Item 1", color: "grey" },
    { text: "Item 2", color: "green" },
    { text: "Item 3", color: "yellow" },
    { text: "Item 4", color: "red" }
];
$(function () {
    $("#radioGroup").dxRadioGroup({
        dataSource: radioGroupItems,
        displayExpr: "text",
        valueExpr: "color",
        value: "green"
    });
});
<div id="radioGroup"></div>
Angular
HTML
TypeScript
<dx-radio-group
    [dataSource]="radioGroupItems"
    displayExpr="text"
    valueExpr="color"
    value="green">
</dx-radio-group>
import { DxRadioGroupModule } from 'devextreme-angular'
// ...
export class AppComponent {
    radioGroupItems = [
        { text: "Item 1", color: "grey" },
        { text: "Item 2", color: "green" },
        { text: "Item 3", color: "yellow" },
        { text: "Item 4", color: "red" }
    ];
}
@NgModule({
    imports: [
        // ...
        DxRadioGroupModule
    ],
    // ...
})
AngularJS
HTML
JavaScript
<div ng-controller="DemoController">
    <div dx-radio-group="{
        dataSource: radioGroupItems,
        displayExpr: 'text',
        valueExpr: 'color',
        value: 'green'
    }"></div>
</div>
angular.module('DemoApp', ['dx'])
    .controller('DemoController', function DemoController($scope) {
        $scope.radioGroupItems = [
            { text: "Item 1", color: "grey" },
            { text: "Item 2", color: "green" },
            { text: "Item 3", color: "yellow" },
            { text: "Item 4", color: "red" }
        ];
    });
Knockout
HTML
JavaScript
<div data-bind="dxRadioGroup: {
    dataSource: radioGroupItems,
    displayExpr: 'text',
    valueExpr: 'color',
    value: 'green'
}"></div>
var viewModel = {
    radioGroupItems: [
        { text: "Item 1", color: "grey" },
        { text: "Item 2", color: "green" },
        { text: "Item 3", color: "yellow" },
        { text: "Item 4", color: "red" }
    ]
};
ko.applyBindings(viewModel);
ASP.NET MVC Controls
Razor C#
Razor VB
@(Html.DevExtreme().RadioGroup()
    .ID("radioGroup")
    .DisplayExpr("text")
    .ValueExpr("color")
    .Value("green")
    .DataSource(new object[] {
        new { text = "Item 1", color = "grey" },
        new { text = "Item 2", color = "green" },
        new { text = "Item 3", color = "yellow" },
        new { text = "Item 4", color = "red" }
    })
)
@(Html.DevExtreme().RadioGroup() _
    .ID("radioGroup") _
    .DisplayExpr("text") _
    .ValueExpr("color") _
    .Value("green") _
    .DataSource(New Object() {
        New With { .text = "Item 1", .color = "grey" },
        New With { .text = "Item 2", .color = "green" },
        New With { .text = "Item 3", .color = "yellow" },
        New With { .text = "Item 4", .color = "red" }
    })
)

View Demo Watch Video

See Also

Configuration

An object defining configuration options for the RadioGroup widget.

Name Description
accessKey

Specifies the shortcut key that sets focus on the widget.

activeStateEnabled

Specifies whether or not the widget changes its state when interacting with a user.

dataSource

A data source used to fetch data the widget should display.

disabled

Specifies whether the widget responds to user interaction.

displayExpr

Specifies the name of the data source item field whose value is displayed by the widget.

elementAttr

Specifies the attributes to be attached to the widget's root element.

focusStateEnabled

Specifies whether the widget can be focused using keyboard navigation.

height

Specifies the widget's height.

hint

Specifies text for a hint that appears when a user pauses on the widget.

hoverStateEnabled

Specifies whether the widget changes its state when a user pauses on it.

isValid

Specifies whether the editor's value is valid.

items

An array of items displayed by the widget.

itemTemplate

Specifies a custom template for items.

layout

Specifies the radio group layout.

name

The value to be assigned to the name attribute of the underlying HTML element.

onContentReady

A handler for the contentReady event. Executed when the widget's content is ready. This handler may be executed multiple times during the widget's lifetime depending on the number of times its content changes.

onDisposing

A handler for the disposing event. Executed when the widget is removed from the DOM using the remove(), empty(), or html() jQuery methods only.

onInitialized

A handler for the initialized event. Executed only once, after the widget is initialized.

onOptionChanged

A handler for the optionChanged event. Executed after an option of the widget is changed.

onValueChanged

A handler for the valueChanged event.

readOnly

A Boolean value specifying whether or not the widget is read-only.

rtlEnabled

Switches the widget to a right-to-left representation.

tabIndex

Specifies the number of the element when the Tab key is used for navigating.

validationError

Specifies information on the validation error when using a custom validation engine. Should be changed at runtime along with the isValid option.

validationMessageMode

Specifies how the message about the validation rules that are not satisfied by this editor's value is displayed.

value

Specifies the currently selected value.

valueExpr

Specifies which data field provides the widget's value. When this option is not set, the value is the entire data object.

visible

Specifies whether the widget is visible.

width

Specifies the widget's width.

Methods

This section describes the members used to manipulate the widget.

Name Description
beginUpdate()

Prevents the widget from refreshing until the endUpdate() method is called.

defaultOptions(rule)

Specifies the device-dependent default configuration options for this component.

dispose()

Disposes of all the resources allocated to the RadioGroup instance.

element()

Gets the root widget element.

endUpdate()

Refreshes the widget after a call of the beginUpdate() method.

focus()

Sets focus on the widget.

getDataSource()

Gets the DataSource instance.

getInstance(element)

Gets the instance of a widget found using its DOM node.

instance()

Gets the widget's instance. Use it to access other methods of the widget.

off(eventName)

Detaches all event handlers from a single event.

off(eventName, eventHandler)

Detaches a particular event handler from a single event.

on(eventName, eventHandler)

Subscribes to an event.

on(events)

Subscribes to events.

option()

Gets all widget options.

option(optionName)

Gets the value of a single option.

option(optionName, optionValue)

Updates the value of a single option.

option(options)

Updates the values of several options.

registerKeyHandler(key, handler)

Registers a handler to be executed when a user presses a specific key.

repaint()

Repaints the widget. Call it if you made modifications that changed the widget's state to invalid.

reset()

Resets the value option to the default value.

Events

This section describes events fired by this widget.

Name Description
contentReady

Raised when the widget's content is ready.

disposing

Raised when the widget is removed from the DOM using the remove(), empty(), or html() jQuery methods only.

initialized

Raised only once, after the widget is initialized.

optionChanged

Raised after a widget option is changed.

valueChanged

Fires when the editor value changes.

See Also

Default Item Template

This section lists the data source fields that are used in a default item template.

Type:

Object

By default, a predefined item template is applied to display the items of this widget. This template is based on certain fields of the data source provided for this widget. Below is the list of these fields. If the default item template is not appropriate for your task, implement a custom item template based on these or other fields of your data source.

See Also