Batch Edit save and delete

5 posts, 0 answers
  1. Geoff
    Geoff avatar
    53 posts
    Member since:
    Aug 2012

    Posted 04 Aug 2014 Link to this post

    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

  2. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 07 Aug 2014 Link to this post

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Geoff
    Geoff avatar
    53 posts
    Member since:
    Aug 2012

    Posted 08 Aug 2014 in reply to Maria Ilieva Link to this post

    Maria,
    That worked great, thank you.

    Regards

    Geoff
  5. Geoff
    Geoff avatar
    53 posts
    Member since:
    Aug 2012

    Posted 20 Aug 2014 in reply to Maria Ilieva Link to this post

    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
  6. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 22 Aug 2014 Link to this post

    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.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017