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

select inserted row after add by js

1 Answer 116 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ali
Top achievements
Rank 1
Ali asked on 16 Apr 2014, 01:56 PM
hi
i have grid in batch mode.i add row addNewRecord in java script now after added i want select this by java script code but inserteditem is null
how can select this row by java script code?

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 17 Apr 2014, 06:23 AM
Hello Ali,

For achieving the desired result you could get reference to the client-side API of the grid, get the dataItems through the MasterTableView and use the set_selected(true) for the first item in the collection (which will be the last added row).

Following is a simple example for selecting the first data item:
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        function selectRow(sender, args) {
            $find("RadGrid1").get_masterTableView().get_dataItems()[0].set_selected(true);
        }
    </script>
</telerik:RadCodeBlock>
 
<asp:HiddenField ID="HiddenField1" runat="server" Value="0" />
 
<telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource">
    <MasterTableView EditMode="Batch" CommandItemDisplay="Top">
    </MasterTableView>
    <ClientSettings>
        <Selecting AllowRowSelect="true" />
        <ClientEvents/>
    </ClientSettings>
</telerik:RadGrid>
 
<telerik:RadButton runat="server" ID="RadButton1" Text="Select last added row" AutoPostBack="false" OnClientClicked="selectRow"></telerik:RadButton>
    

Hope that helps.


Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Ali
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or