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

Get server edited rows in client side

5 Answers 54 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Natan
Top achievements
Rank 1
Natan asked on 16 Oct 2013, 03:47 PM

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

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 17 Oct 2013, 05:04 AM
Hi Natan,

Please try the following to know if the Grid is in EditMode from ClientSide.Attach OnCommand event to RadGrid and check for the command name in the event handler as shown below.

ASPX:
<ClientEvents OnCommand="RadGridCommand" />

JS:
<script type="text/javascript">
function RadGridCommand(sender, args) {
    if (args.get_commandName() == "Edit") {
        alert("In Edit Mode");
    
}
</script>

Thanks,
Shinu

0
Natan
Top achievements
Rank 1
answered on 17 Oct 2013, 07:47 AM
Hi,
Thanks for the reply.
That's not exactly what I need.

What I want is that on some external event (e.g. - user clicks on "close" button of the form)
I will be able to check if the gird is in edit /insert mode or not.
Something like this:
http://stackoverflow.com/questions/8822882/javascript-check-if-radgrid-item-is-in-edit-mode

Only it does not work for me because of the fact I'm editing on server side.

I know I can add a hidden field and set it in the server side.But is there a cleaner way to do this/
0
Jayesh Goyani
Top achievements
Rank 2
answered on 17 Oct 2013, 08:24 AM
Hello,

Please try with the below code snippet.

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script>
            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;
            }
        </script>
    </telerik:RadCodeBlock>


Thanks,
Jayesh Goyani
0
Natan
Top achievements
Rank 1
answered on 17 Oct 2013, 08:41 AM
Hi ,


Like stated in my original post, I can't call get_masterTableView()
,I  get an exception (my guess is that this is  because I perform the edit on the server side).

Thanks,
Omer

0
Maria Ilieva
Telerik team
answered on 21 Oct 2013, 09:11 AM
Hello Natan,

Could you please post the exact page markup as well as the related code behind and also share the exact exception you are receiving when trying to access the MasterTableView? Thus we will be able to further research on your issue and do our best to provide proper solution.

Regards,
Maria Ilieva
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Natan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Natan
Top achievements
Rank 1
Jayesh Goyani
Top achievements
Rank 2
Maria Ilieva
Telerik team
Share this question
or