Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
110
How to get the active DataKey?
posted

Hello,

I have a simple WebDataGrid in the page with a TemplateDataField column, which wraps a "delete item" button as ImageButton. I found no answer on the forums or API how to get the current DataKey when using the delete button.

Here is my code:

 

<%@ Page Title="" Language="C#" MasterPageFile="~/AppMaster.Master" AutoEventWireup="true" CodeBehind="ProjectList.aspx.cs"

    Inherits="Web.Modules.Projects.ProjectList" %>

<%@ Register Assembly="Infragistics4.Web.v10.3, Version=10.3.20103.1013, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb"

    Namespace="Infragistics.Web.UI.GridControls" TagPrefix="ig" %>

<%@ Register Assembly="Infragistics35.WebUI.UltraWebGrid.v10.3, Version=10.3.20103.1013, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb"

    Namespace="Infragistics.WebUI.UltraWebGrid" TagPrefix="ig" %>

<%@ MasterType VirtualPath="~/AppMaster.Master" %>

<asp:Content ID="headContent" ContentPlaceHolderID="headContentHolder" runat="server">

    <script type="text/javascript">

        function pageLoad(sender, args)

        {

            $('input[name*="deleteItem"]').click(function ()

            {

                if (window.confirm("Are you sure you want to delete this item?") == false)

                {

                    return false;

                }

                else

                {

                    // HERE I NEED THE DATAKEY

                    var grid = $.find('<%=pageDataGrid.UniqueID %>');

                    var activeRow = grid.get_behaviors().get_activation().get_activeCell().get_row();

                    window.alert(activeRow.get_dataKey());

                    return false;

                }

            });

        }

    </script>

</asp:Content>

<asp:Content ID="pageActionButtons" ContentPlaceHolderID="pageActionButtonsHolder" runat="server">

</asp:Content>

<asp:Content ID="pageContent" ContentPlaceHolderID="pageContentHolder" runat="server">

    <ig:WebDataGrid ID="pageDataGrid" runat="server" Height="80%" Width="95%" CssClass="grid" DataKeyFields="PRJ_ID" AutoGenerateColumns="false">

        <Columns>

            <ig:TemplateDataField Key="DeleteItem" Width="75px">

                <ItemTemplate>

                    <asp:ImageButton runat="server" ID="displayItem" AlternateText="Display" ImageUrl="~/Library/Resources/images/itemView.gif"

                        OnClientClick="" />

                    <asp:ImageButton runat="server" ID="editItem" AlternateText="Edit" ImageUrl="~/Library/Resources/images/itemEdit.gif"/>

                    <asp:ImageButton runat="server" ID="deleteItem" AlternateText="Delete" ImageUrl="~/Library/Resources/images/itemDelete.gif" />

                </ItemTemplate>

                <Header Text="Actions" Tooltip="Actions for items" />

            </ig:TemplateDataField>

            <ig:BoundDataField DataFieldName="PRJ_ID" Key="PRJ_ID" DataType="System.Int64" Width="10%">

                <Header Text="Id" Tooltip="Project Identifier" />

            </ig:BoundDataField>

            <ig:BoundDataField DataFieldName="DESCR" Key="DESCR" DataType="System.String">

                <Header Text="Name" Tooltip="Project name" />

            </ig:BoundDataField>

        </Columns>

        <Behaviors>

            <ig:Paging PageSize="20" />

        </Behaviors>

    </ig:WebDataGrid>

</asp:Content>

 

Can anybody help on this?

Thanks

 

 

Parents
No Data
Reply
  • 33839
    Suggested Answer
    posted

    Hello calinberindea,

    It looks like you need to turn on Activation behavior.  Otherwise the active cell cannot be found since the  activation behavior will be null on the client.

    regards,
    David Young 

Children