This is a migrated thread and some comments may be shown as answers.

[Solved] Why does get_dataItem() evaluate to null?

1 Answer 276 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Delicious!
Top achievements
Rank 1
Delicious! asked on 18 Feb 2010, 10:25 PM
    <script type="text/javascript">                                                                                                                                            
        function docFileGridOnRowCreated(sender, eventArgs) { } 
        function docFileGridOnRowCreating(sender, eventArgs) { } 
         
        function docFileGridOnRowDblClick(sender, eventArgs)  
        {  
            alert(eventArgs.get_gridDataItem().get_dataItem()); 
        } 
    </script>      
    <style type="text/css">                         
    </style>   
 
       
    <asp:Button ID="btn" runat="server" Text="Save" /> 
    <cym:RadGrid ID="docFileGrid" runat="server" DataSourceID="docFileODS" 
        ClientSettings-ClientEvents-OnRowDblClick=""
        <ClientSettings> 
            <ClientEvents OnRowCreated="docFileGridOnRowCreated" 
                OnRowCreating="docFileGridOnRowCreating" OnRowDblClick="docFileGridOnRowDblClick" />             
        </ClientSettings> 
        <MasterTableView DataKeyNames="AccountFileID, AccountID, FileID, GUID"
            <Columns>                 
                <rad:GridBoundColumn DataField="FileName" HeaderText="Name" />    
        </MasterTableView> 
    </cym:RadGrid> 

I've subscribed to the OnRowCreated/OnRowCreating event as per the documentation's instructions; however, get get_dataItem() and get_dataKeyValue() methods return null.  What am I doing wrong?

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 19 Feb 2010, 05:20 AM
Hello,

The method eventArgs.get_gridDataItem() will return the corresponding dataitem in 'OnRowDblClick' event handler. Then calling the getDataKeyValue() method of dataitem will return key value. Also set the ClientDataKeyNames accordingly.

aspx:
 
    <cym:RadGrid ID="docFileGrid" runat="server" DataSourceID="docFileODS">  
        <ClientSettings>  
            <ClientEvents OnRowCreated="docFileGridOnRowCreated"  
                OnRowCreating="docFileGridOnRowCreating" OnRowDblClick="docFileGridOnRowDblClick" />              
        </ClientSettings>  
        <MasterTableView ClientDataKeyNames="FileName" DataKeyNames="AccountFileID, AccountID, FileID, GUID">  
            <Columns>                  
                <rad:GridBoundColumn DataField="FileName" HeaderText="Name" /> 
            </Columns> 
        </MasterTableView>  
    </cym:RadGrid>  

javascript:
 
    function docFileGridOnRowCreated(sender, eventArgs) { } 
    function docFileGridOnRowCreating(sender, eventArgs) { } 
 
    function docFileGridOnRowDblClick(sender, eventArgs) { 
        alert(eventArgs.get_gridDataItem()); 
        alert(eventArgs.get_gridDataItem().getDataKeyValue("FileName")); 
    } 

-Shinu.
Tags
Grid
Asked by
Delicious!
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or