Telerik Forums
UI for ASP.NET Core Forum
0 answers
251 views

How comes this is displaying a checkbox?   This is an ASP.NET CORE app.  I do have the mobile CSS included (not sure if that is required)

Here is the column and template.   It simply renders as a checkbox.

columns.Bound("").ClientTemplateId("switchTemplate");
<script id="switchTemplate" type="text/x-kendo-template">
    <text>
            @(Html.Kendo().Switch()
                .Name("switch#=Id#")
                .Checked(true)
                .ToClientTemplate()
            )
    </text>
</script>

Jordan
Top achievements
Rank 1
Iron
 asked on 28 Dec 2022
1 answer
493 views
I have a switch that I would like to bind to a model, is this possible?     
Mihaela
Telerik team
 updated answer on 25 Jul 2022
1 answer
1.2K+ views

Hi, I'm new to Telerik ASP.NET Core, so maybe this is a simple task. I'm using Razor Pages and would like to hide the label from one field, how can this be done? From the switch field.

Thanks,

Humberto

                    @(Html.Kendo().Form<ProfileModel>()
                            .Name("formExample")
                            .FormData(Model?.Input)
                            .HtmlAttributes(new { method = "POST" })
                            .Layout("grid")
                            .Grid(g => g.Cols(1).Gutter(0))
                            .Items(items => {
                                items.AddGroup()
                                    .Label("Security")
                                    .Layout("grid")
                                    .Grid(g => g.Cols(2))
                                    .Items(i =>
                                    { 
                                        i.Add()
                                            .Field(f=> f.TFA)
                                            .Editor(e => e.Switch());
                                });

                            })
                            .Validatable(v =>
                            {
                                v.ValidateOnBlur(false);
                                v.ValidationSummary(false);
                                v.ErrorTemplate("<span style='color: red'>#:message#</span>");
                            })
                    )                

Petar
Telerik team
 answered on 15 Feb 2022
1 answer
141 views

I'm having trouble accessing switches in a grid column.  I want to loop through them and toggle them on after clicking a toolbar button.

The click event is working.  But getting 'undefined' on 'switchInstance ':

 

Column with switches code:

.Columns(columns =>
        {

         columns.Bound(p => p.Exempt).Width(100).Filterable(ftb => ftb.Multi(true)).Sortable(false).ClientTemplate(
                "<input class='exemptSwitch' id='exemptSwitch' \\#if (Exempt) { \\# checked='checked' \\# } \\# type='checkbox' />");

})

 

Toolbar button code:

.ToolBar(toolBar =>
        {
            toolBar.Custom()
                .Name("EnableAllFiltered")
                .Text("Enable All Filtered")
                .IconClass("k-icon k-i-play")
                ;

 })

 

Click event code:

$(function () {
    $(".k-grid-ExemptAllFiltered", "#SubscriberGrid").on("click", function (e) {   <--- click of custom grid header toolbar button

         $("#SubscriberGrid .exemptSwitch").each(function () {
               var switchInstance = $(this).data("kendoSwitch");
               switchInstance.enable(true);
          });

});

 

Any assistance would be greatly appreciated!

 

Jon

Tsvetomir
Telerik team
 answered on 20 Oct 2020
2 answers
279 views

How can I set the checked/unchecked messages for my entire application or at least for the page?

Currently, I use something like:

<kendo-switch for="BoundProperty" checked="Model.BoundProperty"><messages checked="@Html.T("Common.YES")" unchecked="@Html.T("Common.NO")" /></kendo-switch>

 

It would be great if I didn't have to include the <messages /> tag each time.

Barry
Top achievements
Rank 1
 answered on 03 Jun 2020
2 answers
347 views

Hello,

I try to change the background color regarding ON or OFF without success (note that .k-switch and .k-switch-handle works perfectly) :

 

<style>
    .k-switch {
        font-size: 12px !important;
    }
    .k-switch-on  {
        background-color: green !important;
    }
    .k-switch-off  {
        background-color: red !important;
    }
    .k-switch-handle{
        background-color: chocolate !important;
    }
</style>

 

Thank you for your precious help.

Louis
Top achievements
Rank 1
Iron
Iron
Iron
 answered on 09 Oct 2019
1 answer
52 views

The same switch control in windos10 system,it can be slide drag:

press the block and drag,if it is samll distance,release the mouse,the block will go back,otherwise the distance exceed 30%-50%

 

 

Dimitar
Telerik team
 answered on 01 May 2019
Narrow your results
Selected tags
Tags
+? more
Top users last month
Dominik
Top achievements
Rank 1
Giuliano
Top achievements
Rank 1
Dominic
Top achievements
Rank 1
Glendys
Top achievements
Rank 1
NoobMaster
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Dominik
Top achievements
Rank 1
Giuliano
Top achievements
Rank 1
Dominic
Top achievements
Rank 1
Glendys
Top achievements
Rank 1
NoobMaster
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?