C1CheckBox Type Parameter

Posted by: james on 8 November 2024, 7:36 pm EST

    • Post Options:
    • Link

    Posted 8 November 2024, 7:36 pm EST

    Hi

    I’m not sure if I missed it, but it doesn’t seem like C1CheckBox has support for a T parameter, so I can be specific that I want to bind to a bool instead of a nullable bool?

    It makes it difficult when I want to bind to my model which has a backend of SQL with a non-nullable bit field. I can make additional properties to do the smarts, but it seems like a lot of extra work and makes it messy especially when I have a lot of them.

    It would be nice if C1CheckBox was flexible in this way, such as MudCheckBox is with a T parameter.

    Is this possible to have as a feature?

    Thanks

    James

  • Posted 11 November 2024, 8:16 am EST

    Hi James,

    Thanks for sharing your use case with us. I have forwarded your use case to the development team to have the T type parameter for the C1CheckBox.

    The internal tracking id for the same is: C1XAML-37340. I will let you know when there is more information on this from the dev team.

    Regards,

    Ankit

  • Posted 11 November 2024, 8:34 pm EST

    Hi Ankit

    Thanks. I appreciate it.

    Kind Regards

    James

  • Posted 15 November 2024, 12:35 am EST

    Is this also possible with the C1DateTimePicker? Such that DateTime can be used for binding instead of a nullable DateTime?

    Thanks

  • Posted 18 November 2024, 10:48 am EST - Updated 18 November 2024, 10:53 am EST

    Hi James,

    The following code sample demonstrates an easy way for binding a valuable value type to the C1CheckBox nullable type:

    <C1CheckBox @bind-IsChecked:set="v=>IsEnabled = v.Value"
                @bind-IsChecked:get="@((bool?)IsEnabled)">
    </C1CheckBox> CheckBox
    
    
    @code {
        public bool? IsEnabled { get; set; } = null;
    }

    You could refer to the following documentation: https://learn.microsoft.com/en-us/aspnet/core/blazor/components/data-binding?view=aspnetcore-9.0

    For the C1DateTimePicker, I believe you could initially set the binding value to be non-nullable DateTime, and thus can be used in this way. If this doesn’t satisfy your use case, I request you to kindly do share your use case so that we could have better understanding of your use case and could help you accordingly.

    Regards,

    Ankit

    C1Binding.zip

  • Posted 21 November 2024, 3:34 am EST

    Hi Ankit.

    Thanks. I will have a look at your sample. I appreciate the response.

    You linked the .net9 documentation, but it looks to be available in .net8 too which is good.

    I’ll give it a shot and see how I go.

    Thanks.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels