Hi,
I have this code here inside the form and only code for the switch(), :
<div class="create-section">
@(
Html.Kendo().Form<WeighmoreSouth32Web.Models.Role>()
.Name("createForm")
.HtmlAttributes(new { action = "Create", method = "POST" })
.Validatable(v =>
{
v.ValidateOnBlur(true);
v.ValidationSummary(vs => vs.Enable(true).TemplateId("validation-message"));
})
.Items(itemGroup =>
{
itemGroup.AddGroup().Layout("grid").Grid(g => g.Cols(3).Gutter(20)).Label("Role Info").Items(items =>
{
items.Add()
.Field(f => f.RoleName)
.Label(l => l.Text("Role Name"));
items.Add()
.Editor(e => e.Switch().Name("AddCustomer")).Field(f => f.AddCustomer)
.Label(l => l.Text("Role Name*:"));
});
})
)
</div>
it is working fine for the textbox input but when I use switch to pass the true value it is passing it two times one true and other one false. But it does not do the same when switch is off, only passes the false value. Here is a picture of it. I did also tried some Js/Jquery code to bind it but it didn't worked as well. Please help.
I have a switch control, placed inside of a tab control, in a client detail template, as part of a grid.
I need to bind the switch checked property, to a value stored in the grids dataset, which is a Boolean. However, the code causes the error:-
Preprocessor directives must appear as the first non-whitespace character on a line
The code is:-
<script id="subsubdetailsTemplate" type="text/kendo-tmpl">
@(Html.Kendo().TabStrip().Name("Tabstrip_#=ReportID#")
.Items(i =>
{
i.Add().Text("Report Details").Selected(true).Content(@<text>
<div>
<p> #=HideOnCatalogue#</p>
Hide from Catalogue?:
@(Html.Kendo().Switch()
.Name("switch_#=ReportID#")
.Events(e => e.Change("function(e){ switchChange(e, '#=ReportID#')}"))
.Checked(#=HideOnCatalogue#)
.Messages(c => c.Checked("YES").Unchecked("NO"))
.ToClientTemplate()
)
</div>
</text>);
}).ToClientTemplate())
</script>
How can I bind the value to the switch? I can display the value in a <p> tag without a problem, as well as passing the report ID to the function called when the switch is clicked.
Thanks
Hi,
I have one table
Emplpyee
..................
Id Name Active
1 a 1
2 b 0
my requirement is that
i have one toggle button (by default select Yes(1))
based upon that values load grid records
once i change that value to No then display records based upon that
can you please provide me sample code for this one
I have multiple switches on a page, each switch has the same class assigned to it.
What i need is that if any switch is checked / changed i need an event to fire and also need to check the state of the remaining switches.
@(Html.Kendo()
.SwitchFor(a => a.IsAdmin)
.HtmlAttributes(new { @class = ".permissions" })
.Messages(c => c.Checked("YES").Unchecked("NO")))
I have tried numerous jquery approaches but none of them even fire when the switch is toggled.
$('body').on('change', '.permissions', function () {
// this event handler never gets trigged.....
// get an instance of each switch and get the toggled / checked state.
alert();
});
I have a case where i need to dynamically clone the switch control and use it.
Im able to clone the switch but the script still refers to the original control .
Tried changing the id and name properties but still not able to achieve it .
Can anyone let me know how to do it .(FYI im not using mobileswitch)
Thanks in advance.
First time working with this control and not sure what I'm missing.
Code:
@(Html.Kendo().SwitchFor(model => model.IsEnabled)
.Messages(c => c.Checked("Enabled").Unchecked("Disabled"))
)
The switch shows up and works, but the true and false message labels do not appear.
I have a form with a couple of switchfor controls on them. They are bond to Boolean properties of my model. When calling a reset on the form, these controls do not revert back to the original value as expected.
<div class="col-1">
<div class="form-group">
<label asp-for="DoNotContact">Ne pas contacter</label><br />
@(Html.Kendo().SwitchFor(m => m.DoNotContact) )
</div>
</div>
What am I doing wrong?
Before version 2019.2 I used MobileSwitch for checkboxes and when I want to clear a form I did this:
1.
_form.reset();
2.
$(_form).find(
"[type=checkbox]"
).each(
function
() {
3.
$(
"#"
+
this
.id).data(
"kendoMobileSwitch"
).refresh();
4.
})
Now, using Switch, I've changed line 3 to
$(
"#"
+
this
.id).data(
"kendoSwitch"
).refresh();
but that didn't work.
How can I achieve the same with new Switch?