UI Widgets RadioGroup

A widget that enables a user to select one item within a list of items represented by radio buttons.

Included in: dx.phonejs.js, dx.webappjs.js, dx.all.js

The dxRadioGroup widget provides a set of options displayed as radio buttons. Selecting one radio button deselects any previously selected radio button.

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

  • jQuery
    Use the dxRadioGroup jQuery plug-in.

    HTML
    <div id="radioGroup"></div>
    JavaScript
    $("#radioGroup").dxRadioGroup({
        dataSource: radioGroupData,
        layout: 'vertical'
    });
  • Knockout
    Add a div element and apply the dxRadioGroup binding to this element.

    HTML
    <div data-bind="dxRadioGroup: {
        dataSource: radioGroupData,
        layout: 'vertical'
    }"></div>
  • Angular
    Add a div element and apply the dx-radio-group directive to this element.

    HTML
    <div dx-radio-group="{
        dataSource: radioGroupData,
        layout: 'vertical'
    }"></div>

Note that DevExtreme widgets require you to link the jQuery and Globalize libraries to your application. If you use the Knockout or Angular approach, the Knockout or Angular library is also required.

See Also

Since the dxRadioGroup widget is used to display multiple items, it supports common Collection Container widget functionality. You can find the detailed information on principles of working with the widget in the dxRadioGroup section of the Collection Container Widgets article.

View Demo

Watch Video

Show Example:
AngularJS
Knockout
jQuery
<div ng-controller="demoController" style="height: 100%;">
    <div class="wrapper" ng-style="{ 'border-color': currentColor }">
        <p><b>Choose border color</b></p>
        <div dx-radio-group="{ 
            items: colors,
            onValueChanged: changeColor,
            valueExpr: 'value',
            bindingOptions: {
                value: 'currentColor'
            }
        }"></div>
    </div>
</div>
var myApp = angular.module('myApp', ['dx']);
myApp.controller("demoController", function ($scope) {
    $scope.colors = [
        { text: "red", value: "#FF0000" },
        { text: "green", value: "#00AA00" },
        { text: "blue", value: "#0000FF" }
    ];
    $scope.currentColor = $scope.colors[0].value;
    $scope.changeColor = function (e) {
        $scope.currentColor = e.value;
    }
});
angular.element(document).ready(function () {
    angular.bootstrap(document, ['myApp']);
});
body{
    text-align: center;
}
.wrapper {
    margin: 10px;
    height: auto;
    padding: 10px;
    border: 2px solid red;
    -moz-border-radius: 10px;
    -webkit-border-radius: 10px;
    border-radius: 10px;
    text-align: center;
}
<div class="wrapper" data-bind="style: { 'border-color': currentColor }">
    <p><b>Choose border color</b></p>
    <div data-bind="dxRadioGroup:{ 
        items: colors,
        onValueChanged: changeColor,
        valueExpr: 'value',
        value: currentColor
    }"></div>
</div>
var myViewModel = {
    colors: [
        { text: "red", value: "#FF0000" },
        { text: "green", value: "#00AA00" },
        { text: "blue", value: "#0000FF" }
    ],
    currentColor: ko.observable("#FF0000"),
    changeColor: function (e) {
        this.currentColor(e.value);
    }
}
ko.applyBindings(myViewModel);
body{
    text-align: center;
}
.wrapper {
    margin: 10px;
    height: auto;
    padding: 10px;
    border: 2px solid red;
    -moz-border-radius: 10px;
    -webkit-border-radius: 10px;
    border-radius: 10px;
    text-align: center;
}
<div class="wrapper" id="radioGroupWrapper">
    <p><b>Choose border color</b></p>
    <div id="myRadioGroup"></div>
</div>
$("#myRadioGroup").dxRadioGroup({
    items: [
        { text: "red", value: "#FF0000" },
        { text: "green", value: "#00AA00" },
        { text: "blue", value: "#0000FF" }
    ],
    value: '#FF0000',
    valueExpr: 'value',
    onValueChanged: function (e) {
        $("#radioGroupWrapper").css({ 'border-color': e.value });
    }
});
body{
    text-align: center;
}
.wrapper {
    margin: 10px;
    height: auto;
    padding: 10px;
    border: 2px solid red;
    -moz-border-radius: 10px;
    -webkit-border-radius: 10px;
    border-radius: 10px;
    text-align: center;
}

Configuration

An object defining configuration options for the dxRadioGroup widget.

Methods

This section describes the members used to manipulate the widget.

Events

This section describes events exposed 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