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