如何检查所选行是否具有特定的联系人职务?
How can I check if selected row has certain contact title?
使用 Kendo UI 演示中为 ASP.NET MVC 找到的示例 index.cshtml,我如何检查我 selected 的行是否有某些联系人头衔?
例如如果我 select 一行并且我想查看该行是否包含联系人职务 'Sales Representative'?我如何在 javaScript 中执行此操作?
我知道我可以将事件绑定到网格,但我不确定如何获取特定行 value/id 并检查联系人头衔是否是销售代表?
这是代码片段:
<div id="clientsDb">
@(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"))
)
)
</div>
<style>
#clientsDb {
width: 952px;
height: 396px;
margin: 20px auto 0;
padding: 51px 4px 0 4px;
background: url('@Url.Content("~/content/web/grid/clientsDb.png")') no-repeat 0 0;
}
</style>
我会给网格一个 Id 并使用以下内容:
将此添加到您的网格:
.Events(events => events.Change("gridClick"))
然后使用这个函数:
function gridClick(){
var grid = $("#gridIdHere").data("kendoGrid");
var selectedRow = grid.dataItem(grid.select());
if(selectedRow.contactTitle == "Sales Representative"){
..Do stuff here
}
}
selectedRow 将包含模型中的所有字段。
使用 Kendo UI 演示中为 ASP.NET MVC 找到的示例 index.cshtml,我如何检查我 selected 的行是否有某些联系人头衔?
例如如果我 select 一行并且我想查看该行是否包含联系人职务 'Sales Representative'?我如何在 javaScript 中执行此操作?
我知道我可以将事件绑定到网格,但我不确定如何获取特定行 value/id 并检查联系人头衔是否是销售代表?
这是代码片段:
<div id="clientsDb">
@(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"))
)
)
</div>
<style>
#clientsDb {
width: 952px;
height: 396px;
margin: 20px auto 0;
padding: 51px 4px 0 4px;
background: url('@Url.Content("~/content/web/grid/clientsDb.png")') no-repeat 0 0;
}
</style>
我会给网格一个 Id 并使用以下内容:
将此添加到您的网格:
.Events(events => events.Change("gridClick"))
然后使用这个函数:
function gridClick(){
var grid = $("#gridIdHere").data("kendoGrid");
var selectedRow = grid.dataItem(grid.select());
if(selectedRow.contactTitle == "Sales Representative"){
..Do stuff here
}
}
selectedRow 将包含模型中的所有字段。