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.

This widget, like any other DevExtreme UI widget, can be created using one of three possible approaches: jQuery, Knockout or AngularJS. The following code demonstrates how to create the dxRadioGroup widget using the Knockout approach.

HTML
<div data-bind="dxRadioGroup:{dataSource: [
        { text: 'Tea' },
        { text: 'Coffee' },
        { text: 'Juice' }
    ],
    layout:'vertical', selectedIndex: 1}">
</div>

The radio group items are loaded from an array specified via the dataSource configuration option. You can specify a simple array or the array of objects as the widget data source.

JavaScript
var employees = [
    { name: "Bob", hired: 2005 },
    { name: "John", hired: 2007 },
    { name: "Frank", hired: 2001 },
];

To display radio group items, a default template is applied based on the following fields of the data source item objects.

  • disabled
    Specifies whether or not the lookup item is disabled
  • visible
    Specifies whether or not the lookup item is visible
  • html
    Specifies the HTML code inserted into the item element
  • text
    Specifies the text inserted into the item element

You can introduce a custom template for lookup items. For this purpose, add a div element with the data-options attribute set to dxTemplate. Assign item to the template name. In this instance, this template will be applied automatically. See the Customize Widget Item Appearance topic to learn more about templates.

HTML
<div data-bind="dxRadioGroup:{dataSource: employees}">
    <div data-options="dxTemplate: {name: 'item'}">
        <span data-bind="text: name"></span> (hired at <span data-bind="text: hired"></span>)
    </div>
</div>
See Also
  • To learn how to create widgets in detail, refer to the Create a Widget article.
  • The dxRadioGroup widget is related to the Collection Containers category. So read an overview of the features that are common for collection container widgets in the Common Tasks topic of the Collection Containers article.

Watch Video

Show Example:
jQuery
<!--<div data-bind="dxRadioGroup: { dataSource: items, layout:'vertical', selectedIndex: 1, 
        	itemSelectAction: function(e) { DevExpress.ui.dialog.alert(e.itemData.text)} }"></div>-->

<div data-bind="dxRadioGroup:{dataSource: employees}">
    <div data-options="dxTemplate: {name: 'item'}">
        <span data-bind="text: name"></span> (hired at <span data-bind="text: hired"></span>)
    </div>
</div>
employees = [
    { name: "Bob", hired: 2005 },
    { name: "John", hired: 2007 },
    { name: "Frank", hired: 2001 },
];

Configuration

An object defining configuration options for the dxRadioGroup widget.

Methods

This section describes members used to manipulate the widget.

Events

This section describes events fired by this component.

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. For details refer to the Customize Widget Item Appearance topic.