BY Ajay Singh27 Sep 2021 Edit
WebAtoms: WA.AtomCheckBoxList Control

Before proceeding to the WA.AtomCheckBoxtList user interface control, let's first understand the simple XF.CheckBox control.

In WebAtoms, to change the state of the checkBox, we need to use the isChecked property and we need to bind it to the control. Single checkBox is primarily used for a terms of service agreements, remember me in login pages, or in YES or NO scenario. XF.CheckBox demo is available from this link.

Create a simple WA.AtomCheckBoxtList.

This selection control allows users to select one or more options from a group of preset choices. WebAtoms facilitates selection of one or more options from the set through the user interface control named WA.AtomCheckBoxList.

Let us first design the layout.

export default class MainPage extends AtomXFContentPage {

    @BindableProperty
    public ethnicities: any[];


    public viewModel: MainPageViewModel;

    public create() {

        this.ethnicities= [];


        this.viewModel = this.resolve(MainPageViewModel);
        this.render(
            <XF.ContentPage title="AtomCheckBoxList Sample">
                <XF.Frame padding="0"
                    backgroundColor={Colors.white}
                    borderColor={Colors.lightGray} >
                    <XF.StackLayout orientation="Vertical" isClippedToBounds="true">
                        <XF.Label text="How would you describe your ethnic origin?"
                            fontSize={22}
                            padding="20,10,0,20"
                            textColor={Colors.black} />
                        <WA.AtomCheckBoxList
                            padding="10"
                            itemsSource={ethiics}
                            selectedItems={Bind.oneWay(() => this.ethnicities)} >
                            <WA.AtomCheckBoxList.itemTemplate>
                                <XF.DataTemplate>
                                    <XF.Label
                                        verticalOptions="Center"
                                        verticalTextAlignment="Center"
                                        fontSize={20}
                                        fontAttributes="Bold"
                                        textColor={Colors.black}
                                        text={Bind.oneWay((x) => x.data)} />
                                </XF.DataTemplate>
                            </WA.AtomCheckBoxList.itemTemplate>
                        </WA.AtomCheckBoxList>
                        <XF.Label
                            fontSize={18}
                            padding="20,10,0,20"
                            text={Bind.oneWay(() => this.ethnicities.length
                                ? this.ethnicities.join(" | ")
                                : "...")}/>
                    </XF.StackLayout>
                </XF.Frame>
            </XF.ContentPage>);
    }

}

The beauty of this control is the customization; one can customize the entire template using DataTemplate.

Now let us understand the property which we have used:

itemsSoruce
selectedItems

To bind the collection of choices we have to use the itemsSource property and that collection of data comes from the mock data.

To collect or show the user selected choices (may be single or multiple ) we have to bind the selectedItems property to this control.

Mock data looks like this.

 const ethiics = [
    "Caucasian",
    "African American",
    "Indian",
    "Asian",
    "Ethnically Ambiguous",
    "Eurasian",
    "European",
    "Hispanic",
    "Semitic",
    "Slavic"
];

This demo can be downloaded from this link.

BY Ajay Singh
LikeCommentSave
LikeCommentSaveShare
0
Categories
General
YantraJS
Developer Guides
Tutorials
Web Atoms Updates

POPULAR POSTS
17 Mar 2021
LATEST ACTIVITY
shubham.neurospeech
liked this post.
Simmi Kava
liked this post.
Show more
ARCHIVES
2021
2020
2019
2018
TAGS
javascript (46)
developer (25)
javascriptdeveloper (15)
Xamarin.Forms (15)
coding (10)
webatoms (10)
xamarin (10)
android (8)
arrays (8)
typescript (8)
csharp (6)
dotnet (5)
function (5)
iOS (5)
update (5)
web-atoms (5)
dotnet-standard (4)
methods (4)
object (4)
xamarin.android (4)
xamarin.io (4)




Web Atoms: JSX (TSX + TypeScript) for Xamarin.Forms, Hot Reload Your App in Production Environment

PlaygroundSamples Repository