뷰가 있습니다. 4 개의 열과 여러 행의 테이블이 있습니다. 문자열 값이 있고 마지막 하나에는 button.My가있는 열이 있습니다. 요구 사항은 버튼을 클릭 할 때 First Column 값을 가져와야한다는 것입니다. 내 코드는 다음과 같이 진행됩니다버튼이있는 마지막 열 클릭시 테이블의 첫 번째 열 값 받기
@(Html.Kendo().Grid<Invoice.Models.ViewModels.Setup.AccountViewModel>()
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.AccountType).Title("Account Type").Width(200);
columns.Bound(p => p.AccountName).Title("Account Name").Width(200);
columns.Bound(p => p.Currency).Title("Currency").Width(200);
columns.Bound(p => p.lkpStatus).Width(225).HtmlAttributes(new { style = "text-align:center" })
.ClientTemplate("# if(data.lkpStatus == 1) " +
"{# <span class='label label-success'>Active</span> #} " +
"else if(data.lkpStatus ==2) {# <span class='label label-warning'>Blocked</span>#}"+
"else {#<span class='label label-important'>InActive</span># } #").Title("Status");
columns.Command(command => command.Edit()).ClientFooterTemplate("stst").Width(200).Title("Action");
}).ToolBar(toolbar =>
{
toolbar.Template(@<text>
<div class="row-fluid">
<div class="span1">
<div class="toolbar" style="height:25px;">
<ul id="menu" style="width:38px; margin-left:22px;" class="span6">
<li style="width:36px;">
<i class="fa fa-plus"></i>
<ul>
@foreach (var account in @ViewBag.AccountType)
{
<li style="width:100px;" class="openid">
@if (@account.Value == "Bank")
{
<label id="Bank1">@account.Value</label>
}
@if (@account.Value == "CreditCard")
{
<label id="Credit">@account.Value</label>
}
@if (@account.Value == "Cash")
{
<label id="Cash1">@account.Value</label>
}
</li>
}
</ul>
</li>
</ul>
</div>
</div>
</div>
</text>);
})
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("UpdateAccount"))
.Pageable()
.Sortable()
.Scrollable()
.Filterable()
.HtmlAttributes(new { style = "height:550px;" })
.DataSource(dataSource => dataSource
.Ajax()
//.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.AccountID))
.Read(read => read.Action("Account_Read", "Setup"))
.Update(update => update.Action("Account_Update", "Setup"))
)
) <script>
$('button').click(function() {
$(this).parent().siblings().each(function() {
alert('index ' + this.cellIndex + ': ' + $(this).text());
});
});
</script>
해결책이 필요합니다 .. – SantyEssac
첫 번째 답변이 제공된 후에 질문을 완전히 바꾸지 마십시오. –