2

我有一个包含以下列的 Infragistics 网格:-

        @(Html.Infragistics().Grid(Model.Rows.AsQueryable())
        .ID("vmClientBankAccounts")
        .Width("100%")
        .Caption("Bank Account List")
        .PrimaryKey("AccountNo")
        .AutoGenerateColumns(false)
        .RowTemplate("<td>${Id}</td><td><a class='accountKey'>${AccountNo}</a></td><td>${Name}</td><td>${AccountType}</td><td>${Status}</td><td>${BranchName}</td><td>${BranchIBT}</td>")
        .Columns(columns =>
            {
                columns.For(x => x.Id).DataType("string").Hidden(true);
                columns.For(x => x.AccountNo).DataType("int").Width("140px");
                columns.For(x => x.Name).DataType("string");
                columns.For(x => x.AccountType).DataType("string").Width("100px");
                columns.For(x => x.Status).DataType("string").Width("110px");
                columns.For(x => x.BranchName).DataType("string").Width("260px");
                columns.For(x => x.BranchIBT).DataType("string").Width("110px");
            })
        .Features(features =>
            {
                features.Paging().PageSize(10).PrevPageLabelText("Previous").NextPageLabelText("Next");
                features.Selection().Mode(SelectionMode.Row).MultipleSelection(false);
            })
        .DataBind()
        .Render()
    )

我有 javascript 在单击网格中的选定行时运行,如下所示:-

<script type="text/javascript">
$(document).ready(function () {

    $('#vmClientBankAccounts td .accountKey').click(function (e) {

        $.ajax({
            type: 'GET',
            url: '/Client/ClientBankAccount',
            data: { bankAccountNo: $(e.target).text() },
            success: function (result) { $('#clientContainer').html(result); }
        });
    });

 });

我需要获取名为“Id”的第一列的单元格值,该列是隐藏列。

使用以下 igGrid 方法,我可以获得任何显示的值,但不知道如何获得隐藏列的值。

        var rowIndex = $("#vmClientBankAccounts").igGrid("selectedRow").IdCellValue;
        var IdCellValue = $($("#vmClientBankAccounts").igGrid("cellAt", 0, rowIndex)).text();

我将不胜感激在这方面的任何帮助,并提前感谢您。

4

2 回答 2

2

在 igGrid 中,没有为隐藏列呈现 html,因此可以通过数据源直接访问该值 - 如果可用,可以通过行索引或行 ID。

例如,要在这种情况下查找所选行的 Id 值,可以使用类似以下内容:

var rowIndex = $("#vmClientBankAccounts").igGrid("selectedRows")[0].index;
var dataSource = $("#vmClientBankAccounts").igGrid("option", "dataSource");
var hiddenIdValue = dataSource[rowIndex].Id;
于 2014-05-23T07:42:18.510 回答
2

正如 Petar 上面的回答,这完全达到了要求。我通过引用最后一行中的.Records对他的建议进行了更改,如下所示,因为它在没有它的情况下返回空引用。

var rowIndex = $("#vmClientBankAccounts").igGrid("selectedRow").index;
var dataSource = $("#vmClientBankAccounts").igGrid("option", "dataSource");
var hiddenIdValue = dataSource.Records[rowIndex].Id;
于 2014-05-23T11:33:56.923 回答