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({
});

You can create the widget using one of the following approaches.

  • jQuery

    HTML
    <div id="radioGroup"></div>
    JavaScript
    var radioGroupItems = [
        { text: "Low", color: "grey" },
        { text: "Normal", color: "green" },
        { text: "Urgent", color: "yellow" },
        { text: "High", color: "red" }
    ];
    $(function () {
        $("#radioGroup").dxRadioGroup({
            dataSource: radioGroupItems,
            displayExpr: "text",
            valueExpr: "color",
            value: "green"
        });
    });
  • Angular

    HTML
    <dx-radio-group
        [dataSource]="radioGroupItems"
        displayExpr="text"
        valueExpr="color"
        value="green">
    </dx-radio-group>
    JavaScript
    export class AppComponent {
        radioGroupItems = [
            // ...
        ];
    }
  • AngularJS

    HTML
    <div ng-controller="DemoController">
        <div dx-radio-group="{
            dataSource: radioGroupItems,
            displayExpr: 'text',
            valueExpr: 'color',
            value: 'green'
        }"></div>
    </div>
    JavaScript
    angular.module('DemoApp', ['dx'])
        .controller('DemoController', function DemoController($scope) {
            $scope.radioGroupItems = [
                // ...
            ];
        });
  • Knockout

    HTML
    <div data-bind="dxRadioGroup: {
        dataSource: radioGroupItems,
        displayExpr: 'text',
        valueExpr: 'color',
        value: 'green'
    }"></div>
    JavaScript
    var viewModel = {
        radioGroupItems: [
            // ...
        ]
    };
    ko.applyBindings(viewModel);
  • ASP.NET MVC Wrappers

    Razor C#
    Razor VB
    @(Html.DevExtreme().RadioGroup()
        .ID("radioGroup")
        .DisplayExpr("text")
        .ValueExpr("color")
        .Value("green")
        .DataSource(new object[] {
            new { text = "Low", color = "grey" },
            new { text = "Normal", color = "green" },
            new { text = "Urgent", color = "yellow" },
            new { text = "High", color = "red" }
        })
    )
    @(Html.DevExtreme().RadioGroup() _
        .ID("radioGroup") _
        .DisplayExpr("text") _
        .ValueExpr("color") _
        .Value("green") _
        .DataSource(New Object() {
            New With { .text = "Low", .color = "grey" },
            New With { .text = "Normal", .color = "green" },
            New With { .text = "Urgent", .color = "yellow" },
            New With { .text = "High", .color = "red" }
        })
    )

Note that DevExtreme widgets require you to link the jQuery library to your application. If you use the Knockout or AngularJS approach, the Knockout or AngularJS library is also required. For detailed information on linking these libraries to your project, refer to the topics in the Installation section.

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.

Default Item Template

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

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