简体   繁体   English

使用 JavaScript 获取 Infragistics WebDataGrid 中单击单元格的值

[英]Get the value of clicked cell in Infragistics WebDataGrid using JavaScript

I have been through this since yesterday and didn't got anything except errors.我从昨天开始就经历了这个,除了错误之外什么都没得到。

What I want is very simple, I want to get the value of a cell when I click on button in a row in Infragistics WebDataGrid using a JavaScript, here is my code:我想要的很简单,当我使用 JavaScript 在 Infragistics WebDataGrid 中单击一行中的按钮时,我想获取单元格的值,这是我的代码:

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
 <script src="Scripts/jquery-1.10.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
    function getCellValue() {
        var grid = $find("WebDataGrid1");
        var usingActivation = grid.get_behaviors().get_selection().get_selectedRows(0).getItem(0).get_cellByColumnKey("test").get_text()
       // var usingRowSelection = grid.get_behaviors().get_activation().get_activeCell().get_row().get_cellByColumnKey("Number").get_text()
    }
</script>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<table class="nav-justified">
    <tr>
        <td>
<ig:WebDataGrid ID="WebDataGrid1" runat="server" Height="350px" Width="400px">
    <Columns>
        <ig:TemplateDataField Key="TemplateField_0">
            <ItemTemplate>
                <asp:Button ID="Button1" runat="server" OnClientClick="getCellValue()" Text="Button" />
            </ItemTemplate>
            <Header Text="TemplateField_0">
            </Header>
        </ig:TemplateDataField>
    </Columns>
    <Behaviors>
        <ig:Activation>
        </ig:Activation>
    </Behaviors>
</ig:WebDataGrid>
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
        </td>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
    </tr>
</table>

When I click on the button I found this error in the chrome debugger;当我点击按钮时,我在 chrome 调试器中发现了这个错误;

在此处输入图片说明

it looks like he didn't find the control "WebDataGrid1", any help please?看起来他没有找到控件“WebDataGrid1”,有什么帮助吗? I'm not that familiar with JS.我对JS不是很熟悉。

Hm, this is strange, could you try with the following as well:嗯,这很奇怪,您也可以尝试以下操作:

var grid = ig_controls.WebDataGrid1;

OR或者

var grid = $find('<%= this.WebDataGrid1.ClientID %>')

grid.get_behaviors().get_selection().get_selectedRows(0).getItem(0).get_cellByColumnKey("test").get_text()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM