在MVC我是用局部视图时,如何通过一个参数标签栏? [英] In MVC How to pass a parameter to tabStrip when I was using Partial Views?
问题描述
在我的视图页面,我有一个按钮。当我按一下按钮,我想使窗口中打开。窗口有一些tabstrips,并且在标签栏我要显示一个网格和一个参数传递给电网。是否剑道UI允许我这样做吗?
剑道窗口 - 如何从我的主视图参数传递给_TabStrip(如参数为paraA字符串)
? @(Html.Kendo()。窗口()
。名称(窗口)
.title伪(关于阿尔瓦阿尔托)
.Content(@ Html.Partial(_ TabStrip控件)。ToHtmlString())
.Draggable()
.Resizable()
.WIDTH(600)
.Actions(行动=方式>。actions.Pin()最小化()最大化()关闭())
.Events(EV = GT; ev.Close(的OnClose))
)
_TabStrip (局部视图)的 - 如何传递对从_TabStrip到_Grid(如参数是主视图paraA字符串)
@(Html.Kendo()。TabStrip控件()
。名称(标签栏)
.SelectedIndex(0)
.Items(项目=>
{
items.Add()
。文本(巴黎)
.Content(@ Html.Partial(_天气)ToHtmlString());
items.Add()
。文本(纽约)
.Content(@ Html.Partial(_网格)ToHtmlString());
})
)
_Weather (部分图)
< DIV CLASS =天气>
&所述; H2> 17&下;跨度>&放大器; ordm;℃下/跨度>&下; / H2>
< P>阴雨天气巴黎及LT; / P>
< / DIV>
<跨度类=梅雨>&安培; NBSP;< / SPAN>
_Grid (部分图) - 如何从_tabStrip获取参数(如参数为paraA从主视图字符串)
@(Html.Kendo()网格和LT。Kendo.Mvc.Examples.Models.CustomerViewModel>()
。名称(网格)
.Columns(列=>
{
columns.Bound(C => c.ContactName).WIDTH(140);
columns.Bound(C => c.ContactTitle).WIDTH(190);
columns.Bound(C => c.CompanyName);
columns.Bound(C => c.Country).WIDTH(110);
})
.HtmlAttributes(新{风格=高度:380px;})
.Scrollable()
.Groupable()
.Sortable()
.Pageable(分页=>分页
.REFRESH(真)
.PageSizes(真)
.ButtonCount(5))
.DataSource(数据源=>数据源
阿贾克斯()
.Read(读取=方式> read.Action(Customers_Read,网格)数据(GetParaFromMainView))
)
)
//如何从主视图参数
功能GetParaFromMainView(){ }
可以传递参数。但是,这将需要你的意见的一些变化。以相同的方式从控制器传递模型是相同的。
我只是写需要更改或添加谁行。
主视图
这行要打开的窗口:
.Content(@ Html.Partial(_ TabStrip控件)。ToHtmlString())
要:
.Content(@ Html.Partial(_ TabStrip控件,paraA).ToHtmlString())
_TabStrip
在你的 _TabStrip.cshtml
视图,您需要添加模型顶部:
@model System.String //或只是字符串
...
而改变这一行:
.Content(@ Html.Partial(_网格)ToHtmlString());
要
.Content(@ Html.Partial(_网格,模型).ToHtmlString());
_Grid
而在你的 _Grid.cshtml
添加到顶部过于模型
@model System.String //或只是字符串
和改变这一行:
.Read(读=方式> read.Action(Customers_Read,网格)的数据(GetParaFromMainView))
)
要
.Read(读=方式> read.Action(Customers_Read,网格)数据(型号))
)
我hopeit将有助于youto解决您的问题。 @ Html.Partial
过载使用通过whichis你的CAS字符串的模式。有一个尝试,让我知道。
In my view page, I have a button. When I click the button, I want to make the window open. The window has some tabstrips, and in the tabstrip I want to show a grid and pass a parameter to the grid. Does kendo UI allow me to do this?
Kendo Window--How to pass a parameter to the _TabStrip from my main view?(like the parameter is "paraA" string)
@(Html.Kendo().Window()
.Name("window")
.Title("About Alvar Aalto")
.Content(@Html.Partial("_TabStrip").ToHtmlString())
.Draggable()
.Resizable()
.Width(600)
.Actions(actions => actions.Pin().Minimize().Maximize().Close())
.Events(ev => ev.Close("onClose"))
)
_TabStrip (Partial View) --How to pass a para from _TabStrip to _Grid?(like the parameter is "paraA" string from main view)
@(Html.Kendo().TabStrip()
.Name("tabstrip")
.SelectedIndex(0)
.Items(items =>
{
items.Add()
.Text("Paris")
.Content(@Html.Partial("_Weather").ToHtmlString());
items.Add()
.Text("New York")
.Content(@Html.Partial("_Grid").ToHtmlString());
})
)
_Weather (Partial View)
<div class="weather">
<h2>17<span>ºC</span></h2>
<p>Rainy weather in Paris.</p>
</div>
<span class="rainy"> </span>
_Grid (Partial View)--How to get the parameter from _tabStrip?(like the parameter is "paraA" string from main view)
@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.CustomerViewModel>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(c => c.ContactName).Width(140);
columns.Bound(c => c.ContactTitle).Width(190);
columns.Bound(c => c.CompanyName);
columns.Bound(c => c.Country).Width(110);
})
.HtmlAttributes(new { style = "height: 380px;" })
.Scrollable()
.Groupable()
.Sortable()
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(5))
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("Customers_Read", "Grid").Data("GetParaFromMainView"))
)
)
//How to get the parameter from main View
function GetParaFromMainView(){
}
You can pass a parameter. But it will require some changes in your views. In the same way you pass the model from the controller it is the same. I will just write the lines who need to be changed or added.
Main View
This line to open the window:
.Content(@Html.Partial("_TabStrip").ToHtmlString())
To:
.Content(@Html.Partial("_TabStrip",paraA).ToHtmlString())
_TabStrip
In your _TabStrip.cshtml
view you need to add the model in the top:
@model System.String //or just string
... And change this line:
.Content(@Html.Partial("_Grid").ToHtmlString());
To
.Content(@Html.Partial("_Grid",Model).ToHtmlString());
_Grid
And in your _Grid.cshtml
add to the top too the model
@model System.String // or just string
And change this line:
.Read(read => read.Action("Customers_Read", "Grid").Data("GetParaFromMainView"))
)
To
.Read(read => read.Action("Customers_Read", "Grid").Data(Model))
)
I hopeit will help youto solve your problem. Use of an overload of @Html.Partial
to pass the model whichis your cas a string. Have a try a let me know.
这篇关于在MVC我是用局部视图时,如何通过一个参数标签栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!