I have a kendo tabstrip which load 3 tab. the first tab loads a kendo panelbar the code is like this
#(Html.Kendo().TabStrip()
.Name("tabstrip")
.Items(tabstrip =>
{
tabstrip.Add().Text("Transactions")
.LoadContentFrom("getgridpanel", "Grid").Selected(true);
tabstrip.Add().Text("Payments").Encoded(false)
.Content(#<text><div class="dr_detail row">
<br>
<br>
</div></text>);
tabstrip.Add().Text("Browse").Encoded(false).HtmlAttributes(new { style = "float:right !important" })
.Content(#<text><div class="dr_detail row">
<br>
<br>
<br>
<br>
</div></text>);
})
)
and the panel inside the first tab is like this:
#(Html.Kendo().PanelBar()
.Name("panelbar")
.ExpandMode(PanelBarExpandMode.Multiple)
.HtmlAttributes(new { style = "width:100%" })
.Items(panelbar =>
{
panelbar.Add().Text("Invoice Details")
.Content(#<text><div class="col-md-2 dr">
<dl>
<dt class="text-left ">Invoice #:</dt>
<dd class="text-left ">
<input class="form-control input-sm" type="text" placeholder="Small Input">
</dd>
</dl>
</div></text>);
panelbar.Add().Text("Payment & Discount");
panelbar.Add().Text("Item Details")
.LoadContentFrom("GetGrid", "Grid", new { grid = Awesome.Web.WebConstants.L_GRID_AGENT });
})
)
when the code is like that it works fine... it renders right but when i try to create a kendo masked textbox in the panelbar like this:
#(Html.Kendo().PanelBar()
.Name("panelbar")
.ExpandMode(PanelBarExpandMode.Multiple)
.HtmlAttributes(new { style = "width:100%" })
.Items(panelbar =>
{
panelbar.Add().Text("Invoice Details")
.Content(#<text><div class="col-md-2 dr">
<dl>
<dt class="text-left ">Invoice #:</dt>
<dd class="text-left ">
#(Html.Kendo().MaskedTextBox()
.Name("Invoice")
.Mask("0000000")
)
</dd>
</dl>
</div></text>);
panelbar.Add().Text("Payment & Discount");
panelbar.Add().Text("Item Details")
.LoadContentFrom("GetGrid", "Grid", new { grid = Awesome.Web.WebConstants.L_GRID_AGENT });
})
)
this code gives me a javascript error: "TypeError: undefined is not a function in /Grid/getgridpanel"
both the tabstrip and the panel are partial views
any help?? is this possibly a bug or conflict of Kendo UI.???
You can not have nested templates inside your mvc helper method-call. The code where you have your MaskedtextBox is causing the problem. What I have done in the past is create an html helper that returns a kendo control, then added the remainder of my kendo markup that includes the nested items, in the main page, like so:
<div>
#MyHelper(parameters).Items(...your code for panel bar here)
</div>
Your help method should return type KendoPanelBar. If you need further clarification, let me know. Good luck.
Related
How can I do a tab strip in kendo ui with render partial...
This is what I have been trying
#(Html.Kendo().TabStrip()
.Name("tabstrip")
.Items(tabstrip =>
{
tabstrip.Add().Text("COES Details")
.Selected(true)
.Content(#<text>
#{Html.RenderPartial("ViewCOESDetails", #Model.COESDetails);}
</text>);
tabstrip.Add().Text("New York")
.Content(#<text>
<div class="weather">
<h2>29<span>ºC</span></h2>
<p>Sunny weather in New York.</p>
</div>
<span class="sunny"> </span>
</text>);
tabstrip.Add().Text("Moscow")
.Content(#<text>
<div class="weather">
<h2>16<span>ºC</span></h2>
<p>Cloudy weather in Moscow.</p>
</div>
<span class="cloudy"> </span>
</text>);
tabstrip.Add().Text("Sydney")
.Content(#<text>
<div class="weather">
<h2>17<span>ºC</span></h2>
<p>Rainy weather in Sidney.</p>
</div>
<span class="rainy"> </span>
</text>);
})
)
It just shows the page on the outside of the tab... what is the correct syntax...
any ideas?
Thanks
tabstrip.Add().Text("COES Details").Enabled(true) .Content(#Html.Partial("path of the Partialview", Model).ToHtmlString());
It now supports controller/actions
#(Html.Kendo().TabStrip()
.Name("tabstrip")
.Items(tabstrip =>
{
tabstrip.Add().Text("File").LoadContentFrom("FileTab","Home");
})
)
and in the Home Controller:
public ActionResult FileTab()
{
return PartialView("_FileTabPartial");
}
Hope this helps
I add multiple partial views to a tab strip. in this case, one partial view per tab:
#(Html.Kendo().TabStrip()
.Name("Information")
.Items(tabstrip =>
{
tabstrip.Add().Text("Tab 1")
.Selected(true)
.Content(Html.Partial("~/Areas/People/Views/Contact/_AustraliaPartial.cshtml", Model.Australia).ToHtmlString());
tabstrip.Add().Text("Tab 2 ")
.Content(Html.Partial("~/Areas/People/Views/Contact/_NewZealandPartial.cshtml", Model.NewZealand).ToHtmlString());
tabstrip.Add().Text("Tab 3")
.Content(Html.Partial("~/Areas/People/Views/Contact/_SamoaPartial.cshtml", Model.Tonga).ToHtmlString());
}))
I have a kendo grid. I am using an add and custom button in the toolbar as the following code:
toolbar: ["create", {
text: "Print record",
className: "k-grid-custom",
imageClass: "k-add"
}],
I also want to add a custom toolbar (dropdown menu) as this example
I used similar code in the demo like
toolbar: kendo.template($("#toolbarIsExpire").html()),
<script type="text/x-kendo-template" id="toolbarIsExpire">
<div class="toolbar">
<label for="is_expired">Is Expired ?</label>
<input type="search" id="is_expired" style="width: 75px;"/>
</div>
</script>
I want to show in the toolbar the add button and my custom button and the dropdown menu (IsExpired)
How to mix between the two toolbar in order to have both of them ?
Extend your template:
<script type="text/x-kendo-template" id="toolbarIsExpire">
<div class="toolbar">
<label for="is_expired">Is Expired ?</label>
<input type="search" id="is_expired" style="width: 75px;"/>
</div>
<a class="k-button k-button-icontext k-grid-add" href="#"><span class="k-icon k-add"> </span>Add new record</a>
</script>
What is the proper way to edit items in a listview when using Kendo UI Mobile & MVVM?
I don't get the expected results when using the following:
HTML
<div id="itemsView"
data-role="view"
data-model="vm">
<ul data-role="listview" data-bind="source: items"
data-template="itemsTemplate">
</ul>
<script id="itemsTemplate" type="text/x-kendo-template">
<li>
#=Name#
</li>
</script>
<input type="text" data-bind="value: newValue" />
<button data-role="button" data-bind="click: update">update</button>
</div>
JavaScript
var vm = kendo.observable({
items: [{
Name: "Item1"}],
newValue: '',
update: function(e) {
var item = this.get("items")[0];
item.set("Name", this.get("newValue"));
//adding the follwoing line makes it work as expected
kendo.bind($('#itemsView'), vm);
}
});
kendoApp = new kendo.mobile.Application(document.body, {
transition: "slide"});
I expect the listview to reflect the change to the Name property of that item. Instead, a new item is added to the listview. Examining the array reveals that there is no additional item, and that the change was made. (re)Binding the view to the view-model updates the list to reflect the change. Re-Binding after a change like this doesn't seem to make any sense.
Here is the jsfiddle:
http://jsfiddle.net/5aCYp/2/
Not sure if I understand your question properly: but this is how I did something similar with Kendo Web UI, I expect mobile is not so different from Web UI from API perspective.
$element.kendoListView({
dataSource: list,
template: idt,
editTemplate: iet,
autoBind: true
});
The way I bind the listview is different, but I guess you can get similar results with your method as well.
I pass two templates to the list view, one for displaying and one for editing.
Display template contains a button (or any element) with css class k-edit to which kendo will automatically bind the listview edit action.
display template:
<div class="item">
# if (city) { #
#: city #<br />
# } #
# if (postCode) { #
#: postCode #<br />
# } #
<div class="btn">
<span class="k-icon k-edit"></span>Edit
<span class="k-icon k-delete"></span>Delete
</div>
</div>
Edit template
<div class="item editable">
<div>City</div>
<div>
<input type="text" data-bind="value: city" name="city" required="required" validationmessage="*" />
<span data-for="city" class="k-invalid-msg"></span>
</div>
<div>Post Code</div>
<div>
<input type="text" data-bind="value: postCode" name="postCode" required="required" validationmessage="*" />
<span data-for="postCode" class="k-invalid-msg"></span>
</div>
<div class="btn">
<span class="k-icon k-update"></span>Save
<span class="k-icon k-cancel"></span>Cancel
</div>
</div>
Clicking that element will put the current element on edit mode using the editTemplate.
Then on the editTemplate there is another button with k-update class, again to which kendo will automatically bind and call the save method on the data source.
Hopefully this will give you more ideas on how to solve your issue.
The problem was caused by the <li> in the template. The widget already supplies the <li> so the additional <li> messes up the rendering. This question was answered by Petyo in the kendo ui forums
I am trying to create a page which has Telerik Editor control. Use can create email templates using this screen. when I have put this Control in side #Html.BeginForm it works. I mean then i am able to get the value in my Controller .
When I create the form tag and put this Editor inside that tag, it does not work. The value comes as null in my controller.
WORK :-
#using (Html.BeginForm("Create", "Template", FormMethod.Post, new { #class = "ajax-form" }))
{
<div class="file-contents">
<div class="editor-label">
#Html.LabelFor(model => model.Contents)
</div>
<div class="editor-field">
#(Html.Telerik().EditorFor(model => model.Contents)
.HtmlAttributes(new { style = "width: 600px; height: 300px;" })
.Encode(false)
)
#Html.ValidationMessageFor(model => model.Contents)
</div>
</div>
}
Does not work.
<form dojoType="dijit.form.Form" id="createTemplateForm" jsId="createTemplateForm" encType="multipart/form-data" action="#Url.Action("Create", "Template")" method="POST"> <div class="file-contents">
<div class="editor-label">
#Html.LabelFor(model => model.Contents)
</div>
<div class="editor-field">
#(Html.Telerik().EditorFor(model => model.Contents)
.HtmlAttributes(new { style = "width: 600px; height: 300px;" })
.Encode(false)
)
#Html.ValidationMessageFor(model => model.Contents)
</div>
</div>
</form>
Any idea why is this happening? Please let me know.
Thanks.
In order for the two to match up, the "name" attribute has to be set correctly.
Make sure on the version with the form tag, the "name" attribute is set correctly on the Telerik input.
If it is not, you can add it by passing an object of html settings (should be one of the overloads)
I have a farily straight forward form that renders personal data as a partial view in the center of the form. I can not get client side validation to work on this form.
I started chasing down the generate html and came up with the same model field rendered on a standard form and a partial view.
I noticed that the input elements are correctly populated on the first call, #html.partial, the following only happens when the partialview is reloaded via an ajax request.
First the header of my partial view, this is within a Ajax.BeginForm on the main page.
#model MvcMPAPool.ViewModels.EventRegistration
<script src="#Url.Content("~/Scripts/jquery.validate.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function ()
{
$(".phoneMask").mask("(999) 999-9999");
});
</script>
#{
var nPhn = 0;
var dTotal = 0.0D;
var ajaxOpts = new AjaxOptions{ HttpMethod="Post", UpdateTargetId="idRegistrationSummary", OnSuccess="PostOnSuccess" };
Html.EnableClientValidation( true );
Html.EnableUnobtrusiveJavaScript( true );
}
Here is the razor markup from the partial view:
#Html.ValidationMessageFor(model=>Model.Player.Person.Addresses[0].PostalCode)
<table>
<tr>
<td style="width:200px;">City*</td>
<td>State</td>
<td>Zip/Postal Code</td>
</tr>
<tr>
<td>#Html.TextBoxFor(p=>Model.Player.Person.Addresses[0].CityName, new { style="width:200px;", maxlength=50 })</td>
<td>
#Html.DropDownListFor(p=> Model.Player.Person.Addresses[0].StateCode
, MPAUtils.GetStateList(Model.Player.Person.Addresses[0].StateCode))</td>
<td>
<div class="editor-field">
#Html.TextBoxFor(p=>Model.Player.Person.Addresses[0].PostalCode, new { style="width:80px;", maxlength=10 })
</div>
</td>
</tr>
</table>
Here is the rendered field from the partial view:
<td>
<div class="editor-field">
<input id="Player_Person_Addresses_0__PostalCode" maxlength="10" name="Player.Person.Addresses[0].PostalCode" style="width:80px;" type="text" value="" />
</div>
</td>
Here is the same model field rendered in a standard view:
<div class="editor-field">
<input data-val="true" data-val-length="The field Postal/Zip Code must be a string with a maximum length of 10." data-val-length-max="10" data-val-required="Postal or Zip code must be provided!" id="Person_Addresses_0__PostalCode" maxlength="10" name="Person.Addresses[0].PostalCode" title="Postal/Zip Code is required" type="text" value="" />
<span class="field-validation-valid" data-valmsg-for="Person.Addresses[0].PostalCode" data-valmsg-replace="true"></span>
</div>
Notice that the partial view rendering has no data-val-xxx attributes on the input element.
Is this correct? I do not see how the client side validation could work without these attributes, or am I missing something basic here?
In order to create the unobtrusive validation attributes, a FormContext must exist. Add the following at the top of your partial view:
if (this.ViewContext.FormContext == null)
{
this.ViewContext.FormContext = new FormContext();
}
If you want the data validation tags to be there, you need to be in a FormContext. Hence, if you're dynamically generating parts of your form, you need to include the following line in your partial view:
#{ if(ViewContext.FormContext == null) {ViewContext.FormContext = new FormContext(); }}
You then need to make sure you dynamically rebind your unobtrusive validation each time you add/remove items:
$("#form").removeData("validator");
$("#form").removeData("unobtrusiveValidation");
$.validator.unobtrusive.parse("#form");