Radio Group
- It will repeat the radio buttons.
- It is single select.
Features/ Functionality
Click functionality on each radio button.
It will repeat in horizontal direction but if the width of outer div is small, it will wrap.
Component is container responsive.
It is cross browser compatible. (IE11, Edge, Firefox, chrome).
Basic Usage
Dependency
- jquery
- font awesome
- shared styles
- shared scripts
HTML Structure
<require from="{user_path}/radio_groups/radio_group"></require>
<cst-radio-group items.bind="{items}" input-id.bind="{inputId}" readable-item.bind="{readableItem}" options.bind="{options}" other-info.bind="{otherInfo}" ext-disabled.bind="{disabled}" evt-click-callback.bind="{evtClickCallback}"></cst-radio-group>
Bindable Properties
Property | Data Type | Required | Description |
---|---|---|---|
items | array | Yes | Data to be passed to component. |
inputId | string/int | No | Selected value's id will be set in inputId. It is two way communication property. Once the data sent will be set, then whatever selected value changes page can get it.(Data type as per optins.propId) |
readableItem | object | No | To get selected value in this object. Inisially bind this object as empty. |
options | object | No | Basic component options |
otherInfo | any | No | Extra info to be passed on event |
extDisabled | boolean | No | Disables any functionality on component. |
evtClickCallback | method | No | Method to be called on click event. |
Structure of bindable properties
items
items = [
{
id: '', // id is required
label: ''
},...
]
readableItem
readableItem = {} // If we want selected value in this object, pass it as empty
options
options = {
propId: '', // This is the key of items object, which we consider as id. Default value = 'id'.
propLabel: '', // This is the key of items object, which we consider as label. Default value = 'label'.
pageLabel: {}, // Override page labels
pageColorData: {} // Override css colour porperty
}
evtClickCallback
evtClickCallback(_event,_info);
_info = {
overrideContext: overrideContext,
otherInfo: otherInfo,
value: item
}
CSS Overrinding
- Following classes are given to override CSS:
- .cst-radio-group-container-override : Container Class
- .cst-radio-group-element-override: Element Class
Note
- While giving the classes in page, give them in nested structure.
Rules
Component measurements
** box-sizing: border-box is used. So width and height will be dimensions + padding.
Working Example
HTML
<template>
<require from="./shared/core_comp/radio_groups/radio_groups"></require>
<div>
<cst-radio-group items.bind="items" input-id.bind="inputId" readable-item.bind="readableItem" options.bind="options" other-info.bind="otherInfo" ext-disabled.bind="disabled" evt-click-callback.bind="evtClickCallback"></cst-radio-group>
</div>
</template>
CSS
.cst-ex-radio-group{
.cst-radio-group-element-override {
margin-right: 20px !important;
}
.cst-radio-group-container-override {
justify-content: center !important;
}
}
JS
class MyCls{
constructor(){
this.otherInfo = {
qId : '1'
}
this.items = [
{
key: 1,
value: 'Male'
},
{
key: 2,
value: 'Female'
},
{
key: 3,
value: 'Others'
}
];
this.inputId = 3;
this.options = {
propId: 'key', // If items object's property is not id
propLabel: 'value' // If items object's property is not label
};
this.disabled = false;
this.readableItem = {};
}
evtClickCallback(_event,_info){
console.log(_event);
console.log(_info);
}
}
export { MyCls }
Example Screen Shots
Desktop
IE Desktop
Tab
Mobile
Demo Link
Demo
Mark down usage
https://guides.github.com/features/mastering-markdown/
Version | Date | Developed By | Information Classification | Reviewed By | Approved By |
---|---|---|---|---|---|
1.0 | 12-10-2019 | Tarun | INTERNAL | Gunjan and Prasan | Prasan |