radgrid -get server edited rows in client side

I have a radgrid asp.net control and in it I'm editing the rows on the server side. I want to know in the client side in case the user tries to close the screen before saving/discarding changes in the grid.

I found some explenations on how to do this using : get_masterTableView

However, since I'm not editing in client side, calling this function results in an exception (inside it there is a call to get_id that fails).

How can I know if the grid is in edit mode or not on the client side?

Thanks, Omer



I havent worked more on RadGrid. Instead I can give you a workaround. Try, might work. Its quite simple.

You can use hidden field. When you enter the grids editing mode you can set hidden fields value to true or whatever you want from code behind. Clean that value on row commit, so that you identify that grid is open for editing or not. If a user closes the form or do any thing then you can detect the hidden value from javascript.

thats it.


Please try with the below code snippet.

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            function getEditInsertCount() {

                var grid = $find("<%= RadGrid1.ClientID %>");
                if (grid) {
                    var MasterTable = grid.get_masterTableView();
                    if (MasterTable.get_insertItem() != null) {
                        alert('grid in insert mode');

                    if (grid.get_editItems().length > 0) {
                        alert('grid in edit mode, Row count: ' + grid.get_editItems().length);

                return false;

Edit 1 : (Other part of code)


        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"></telerik:RadAjaxLoadingPanel>
        <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" OnNeedDataSource="RadGrid1_NeedDataSource"
            AllowFilteringByColumn="true" AllowMultiRowEdit="true">
            <MasterTableView CommandItemDisplay="Top" DataKeyNames="ID" EditMode="InPlace">
                    <telerik:GridBoundColumn DataField="ID" UniqueName="ID" HeaderText="ID"></telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Name" UniqueName="Name" HeaderText="Name" HtmlEncode="true"></telerik:GridBoundColumn>
        <asp:Button ID="Button1" runat="server" Text="Get Insert and Edit stauts" OnClientClick="return getEditInsertCount();" />


protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    DataTable dt = new DataTable();

    dt.Columns.Add("ID", typeof(int));
    dt.Columns.Add("Name", typeof(string));
    dt.Columns.Add("Customdate", typeof(DateTime));

    dt.Rows.Add(1, "name1", DateTime.Now);
    dt.Rows.Add(2, "name2", DateTime.Now.AddYears(-1));
    dt.Rows.Add(3, "name3", DateTime.Now.AddYears(1));

    RadGrid1.DataSource = dt;


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.