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

Batch Edit save and delete

4 Answers 269 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Geoff
Top achievements
Rank 1
Geoff asked on 04 Aug 2014, 03:22 PM
Hi,
I currently have a Grid using batch edit mode (working quite nicely thanks to Telerik support) but I need to add a couple of features that are proving quite troublesome for me to implement.

The first is that the Save command in the grid is fine but I also have an ASP button on the page called "Post", which changes the status of the records entered (via SQL run from the codebehind). However, I would like the "Post" button to also save any changed/new/deleted records before it does its own thing.

I found client-side code (see below) that I thought would do the trick but its effects are overridden by the postback from the "Post" button.
var grid = $find("<%=RadGrid1.ClientID%>");
grid.get_batchEditingManager().saveChanges(grid.get_masterTableView());

Is there a way I can do this?

I have a similar problem with deleting records. Basically, I'm using a GridButtonColumn to provide a delete option but the deletes don't apply unless the user presses the save button. Our users keep missing this because once they see that the row has gone, they think the delete operation is complete. Is it possible to save the changes when the user either navigates away (using a control on the screen) or presses the "Post" button?

Regards

Geoff Scott

4 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 07 Aug 2014, 02:25 PM
Hello Geoff,

Try attaching the client function as follow:
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Post" onclientclick="return saveChanges();"/>

This should prevent he post back before the client code executes.

Regards,
Maria Ilieva
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.

 
0
Geoff
Top achievements
Rank 1
answered on 08 Aug 2014, 10:32 AM
Maria,
That worked great, thank you.

Regards

Geoff
0
Geoff
Top achievements
Rank 1
answered on 20 Aug 2014, 09:20 AM
Maria,
Well I thought it worked great. It turns out that it works great on Google Chrome, Firefox and IE8. However, on IE9, IE10 & IE11 there is a problem. The client JavaScript runs fine but the button's assoiated server side codebehind just doesn't run at all. I mean it's not even called. I put a breakpoint on the first line of code and it never gets hit. Have you come across this at all?

Regards

Geoff
0
Maria Ilieva
Telerik team
answered on 22 Aug 2014, 11:36 AM
Hello Geoff,

If your java script function would return true, your server side code would process. Returning false prevents the page from posting back to the server.
In your case you could suggest registering the client script function on the server ButtonClick event like this:
protected void Button1_Click(object sender, EventArgs e)
    {
    ScriptManager.RegisterStartupScript(this, GetType(), "YourUniqueScriptKey",
        "saveChanges", true);
}


Using this approach will guarantee that the server and the client functions will executes properly.

Regards,
Maria Ilieva
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
Geoff
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Geoff
Top achievements
Rank 1
Share this question
or