how to use render partial in a kendo ui tab strip - kendo-ui

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());
}))

Related

How to filter through assertion on deep child div content but yield original element?

I have a DOM tree and would like to use cypress to do e2e testing.
<div class="this-is-an-array">
<div class="array-item-element">
...
</div>
<div class="array-item-element">
<div class="very">
<div class="deep">
<div class="child">
<div class="element">
Expected Content
</div>
</div>
</div>
</div>
<div class="another">
<div class="component">
<div class="dom">
<div class="tree">
<button>ButtonToClick</button>
</div>
</div>
</div>
</div>
</div>
<div class="array-item-element">
...
</div>
</div>
I would like to filter out expected item by asserting on its one child component and click on its another child button through possible code like this:
cy.get('.this-is-an-array') // get the root node of array
.find('.array-item-element') // looping over all items
.should(($el) => {
// the very deep child element should contain text of 'Expected Content'
})
.get('.another .component .dom .tree button')
.click()
How can I write the should clause to achieve this?
Without fully understanding what you're trying to do, I think what you need is cy.within():
cy.get(`.this-is-an-array`)
.find(`.array-item-element`).then( $elems => {
$elems.each((idx, elem) => {
cy.wrap(elem)
.should(elem => {
// assert on child element
})
// ensure all subsequent DOM commands are scoped within
// the wrapped DOM elem
.within(() => {
cy.get(`.another .component .dom .tree button`)
.click();
});
});
});

Nested kendo panel on a Kendo Tabstrip not Rendering

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.

form tag doesn't render in partial view with jquery dialog. mvc3 asp.net

i have a partial view "CreateJobLine.cshtml" that contains a form. this form when rendered using #Html.Action method creates the form fields without the form tag. i used the Html.BeginForm as well as hard coded the form (below), but in both situation its not generating the tag. I am also using jqueryui's dialog widget to display the form.
---Partial View ---
//filename: CreateJobLine.cshtml
#model Recruitment.Models.JobLine
#if(false){
<script src="#Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
}
<div id="addnewjoblinediv">
<form id="createjoblineform" action="#Url.Action("CreateJobLine")" method="post">
#Html.ValidationSummary(true)
<fieldset>
<legend>JobLine</legend>
#Html.Hidden("job_id", Model.JobId)
<div class="editor-label">
#Html.LabelFor(model => model.Description)
</div>
<div class="editor-field">
#Html.EditorFor(model => model.Description)
#Html.ValidationMessageFor(model => model.Description)
</div>
<div class="editor-label">
#Html.LabelFor(model => model.TimeSpent)
</div>
<div class="editor-field">
#Html.EditorFor(model => model.TimeSpent)
#Html.ValidationMessageFor(model => model.TimeSpent)
</div>
<div class="editor-label">
#Html.LabelFor(model => model.JobId)
</div>
<div class="editor-field">
#Html.DisplayFor(model => model.JobId)
#Html.ValidationMessageFor(model => model.JobId)
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
</form>
</div>
In the edit view, I have Html.Action call to load the partial view.
---Edit View---
//filename Edit.cshtml
...
#Html.Action("CreateJobLine", "Job", new { job_id = Model.Job.JobId})
<a id="addnewjoblinelink" href="#">Add New JobLine</a>
</fieldset>
}
<script type="text/javascript">
$(document).ready(function () {
$("div#addnewjoblinediv").dialog({ autoOpen: false, modal:true, width:550, title:"Add New JobLine"});
$("a#addnewjoblinelink").click(function () {
$("div#addnewjoblinediv").dialog("open");
}
);
}
);
</script>
Here is the controller
---Job Controller---
//JobController.cs
...
[HttpGet]
public PartialViewResult CreateJobLine(int job_id)
{
var jobline = new JobLine();
jobline.JobId = job_id;
jobline.TimeSpent = 0;
return PartialView(jobline);
}
[HttpPost]
public ActionResult CreateJobLine(JobLine jobline)
{
if (ModelState.IsValid)
{
db.JobLines.Add(jobline);
db.SaveChanges();
return RedirectToAction("Index");
}
return RedirectToAction("Edit", new { id = jobline.JobId });
}
...
call to /Job/CreateJobLine/5 gets the form content with all the form elements, but the form tag itself is missing. I want to get that form action be set to /Job/CreateJobLine post method so that I can create a JobLine.
Thank you.
I think your problem is #Html.Action. I believe it's simpler and closer to what you want to just render a partial view like this:
#{ Html.RenderPartial("CreateJobLine", new MvcApplication1.Models.JobLine { JobId = 10 }); }
I say that because when I use RenderPartial like I would normally do, the form is rendered correctly inside the dialog (all the rest of the code is how you posted it). I can't use Html.Action with the code you posted (probably because you omitted something else), so that indicates to me your problem is around that method. Good luck.

ASP.NET MVC Telerik Editor does not work with form tag

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)

The model item passed into the dictionary is of type... ut this dictionary requires a model item of type

I'm new to exploring MVC3 and came up with a problem.
I'm editing my Master view and want the login boxes to be visible on every page when a user isn't logged in. I've done this by using this code:
#if (Request.IsAuthenticated)
{
<text>Welcome <strong>#User.Identity.Name</strong>!
[ #Html.ActionLink("Log Off", "LogOff", "Account") ]</text>
}
else
{
Html.RenderPartial("../Account/LogOn");
}
This works when going to my normal Index method of the HomeController.
However, when going to the Index method of my NewsController I get the following error:
The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[LeagueSite.Models.News]', but this dictionary requires a model item of type 'LeagueSite.Models.LogOnModel'.
I understand what the problem is but don't really know a sollution for it.
The view LogOn looks like this (standard MVC3 logon view):
#model LeagueSite.Models.LogOnModel
#{
ViewBag.Title = "Log On";
}
<h2>Login</h2>
<p>
Please enter your user name and password. #Html.ActionLink("Register", "Register") if you don't have an account.
</p>
<script src="#Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
#Html.ValidationSummary(true, "Login was unsuccessful. Please correct the errors and try again.")
#using (Html.BeginForm()) {
<div>
<fieldset>
<legend>Account Information</legend>
<div class="editor-label">
#Html.LabelFor(m => m.UserName)
</div>
<div class="editor-field">
#Html.TextBoxFor(m => m.UserName)
#Html.ValidationMessageFor(m => m.UserName)
</div>
<div class="editor-label">
#Html.LabelFor(m => m.Password)
</div>
<div class="editor-field">
#Html.PasswordFor(m => m.Password)
#Html.ValidationMessageFor(m => m.Password)
</div>
<div class="editor-label">
#Html.CheckBoxFor(m => m.RememberMe)
#Html.LabelFor(m => m.RememberMe)
</div>
<p>
<input type="submit" value="Log On" />
</p>
</fieldset>
</div>
}
`
Any tips/ideas?
Quick and dirty: instead of Html.RenderPartial use Html.RenderAction:
Html.RenderAction("LogOn", "Account");
and in the LogOn action of the Account controller ensure to return a PartialView or you will get a stack overflow and Cassini will crash:
public ActionResult LogOn()
{
return PartialView();
}
I think your "news" view has already a model associated to it.
maybe it starts like this?:
#model LeagueSite.Models.News
well, if so, if you are not passing a model to your partial view, then the framework assumes by default that the model for that partial is "LeagueSite.Models.News", which of course isn't what you want. You must pass the LogOnModel to your LogOn partial view like this:
Html.RenderPartial("../Account/LogOn", Model.ObjLogonModel);
this assumes that you have an instance of LogonModel into your "News" model. then you'll be able to handle the Logon action
regards

Resources