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>
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>");
})
)
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
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.
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.
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%