2014-05-22 93 views
1

我有一個Infragistics的網格有以下的列的單元格的值: -獲取隱藏igGrid列

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

}); 

我需要得到我的名爲「身份證」,這是一個隱藏列第一列的單元格值。

使用以下方法igGrid我能夠獲得任何所顯示的數值,但不知道如何獲取隱藏的列值。

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

我希望在這方面提供任何幫助,並提前致謝。

回答

1

在igGrid HTML是不呈現爲隱藏列因此訪問值可以通過數據源直接做 - 或者由行索引或行ID(如果可用)。

例如,要找到在這種情況下選擇行的ID值,可以使用類似於下面的東西:

var rowIndex = $("#vmClientBankAccounts").igGrid("selectedRows")[0].index; 
var dataSource = $("#vmClientBankAccounts").igGrid("option", "dataSource"); 
var hiddenIdValue = dataSource[rowIndex].Id; 
2

正如上面佩塔爾迴應,這是實現需要什麼。 我在最後一行引用.Records如下,因爲它沒有它返回一個空引用一個變化他的建議。

var rowIndex = $("#vmClientBankAccounts").igGrid("selectedRow").index; 
var dataSource = $("#vmClientBankAccounts").igGrid("option", "dataSource"); 
var hiddenIdValue = dataSource.Records[rowIndex].Id;