RadioGroup

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.

Included in: dx.mobile.js, dx.web.js, dx.viz-web.js, dx.all.js
Module: ui/radio_group
Export: default
RadioGroup interactive configuration
Copy Code
Copy to Codepen
$("#radiogroup").dxRadioGroup({
});

                    

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
Show Example:
AngularJS
Knockout
jQuery

Configuration

An object defining configuration options for the RadioGroup widget.

Methods

This section describes the members used to manipulate the widget.

Events

This section describes events fired by this widget.

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