1

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:

<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;

enter image description here

it looks like he didn't find the control "WebDataGrid1", any help please? I'm not that familiar with JS.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Osama Gadour
  • 177
  • 2
  • 17

1 Answers1

2

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()
Zdravko Kolev
  • 1,569
  • 14
  • 20
  • 1
    this is right, as the Grid was inside a content holder i used the second solution ( it was answered in Infragistics forums, but I will give you the accepted answer). thanks, – Osama Gadour Feb 10 '20 at 08:17