Default empty grid to Insert mode on form load

5 posts, 0 answers
  1. Troy
    Troy avatar
    11 posts
    Member since:
    Aug 2012

    Posted 22 Dec 2013 Link to this post

    Hi I have a form with some fields and a radgrid. When the form is opened and if the grids datasource is empty, I want the grid to go into edit mode automatically without the user having to press "Add New Record" first.

    I use the grid in batch edit mode as described in this example...
    http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/batch-editing/defaultcs.aspx

    After some quick research I've seen advice to use using the following code....
    RadGrid1.MasterTableView.IsItemInserted = true
    RadGrid1.Rebind()

    But unfortunately this just displays the "in-place" edit form rather than simulating "Add New Record" when the grid is in batch editing mode.

    Also is it possible to have a custom "Save Changes" and "Cancel Changes" button outside of the grid control elsewhere on the form? This is because I want to allow the users to edit other controls on the form but I want one "Save Changes" button to update everything. My custom Save Changes button will save outher edits on the form and also the grid edits.










  2. Eyup
    Admin
    Eyup avatar
    3013 posts

    Posted 25 Dec 2013 Link to this post

    Hi Troy,

    You can use the addNewRecord and saveChanges methods to achieve the requested functionality:
    http://www.telerik.com/help/aspnet-ajax/grid-batch-editing.html

    You can find an sample in the following thread:
    http://www.telerik.com/community/forums/aspnet-ajax/grid/how-to-fire-the-updateedited-method-from-an-outside-button.aspx

    Hope this helps. Please give it a try and let me know if it works for you.

    Regards,
    Eyup
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Troy
    Troy avatar
    11 posts
    Member since:
    Aug 2012

    Posted 28 Dec 2013 Link to this post

    Thanks, I've got the desired functionality working now.

    One issue though...

    I couldn't trigger initSaveAllCommand();  in the example using a RadButton. I had to use a normal asp button.

    This worked...

    <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="initSaveAllCommand(); return false;" />

    This did not work...

    <telerik:RadButton ID="Button1" runat="server" Text="Button" OnClientClick="initSaveAllCommand(); return false;" />

    What if I want to use a RadButton instead of a normal ASP Button?

  5. Troy
    Troy avatar
    11 posts
    Member since:
    Aug 2012

    Posted 28 Dec 2013 Link to this post

    I figured out why RadButton wasn't working on click.

    I need to use "OnClientClicked" and the function name without brackets.

    So the client side function now fires on clicking BUT I also want to fire a server side function and the server side function is not working.

    Any help would be appreciated :)

    So my code for this currently is ...

    <telerik:RadButton ID="btnUpdate" runat="server" Text="Update" Font-Bold="True" OnClientClicked="initSaveAllCommand" OnClick="btnUpdate_Click"

    Width="90px" CssClass="buttonFloatRight" AutoPostBack="true" CausesValidation="false" />

     Protected Sub btnUpdate_Click(sender As Object, e As System.EventArgs) Handles btnUpdate.Click
         ' this is not firing :-(
     End Sub

  6. Eyup
    Admin
    Eyup avatar
    3013 posts

    Posted 30 Dec 2013 Link to this post

    Hello Troy,

    Please disable the AutoPostBack property of the button and try using the ItemCommand or BatchEditCommand event of the grid:
    http://www.telerik.com/help/aspnet-ajax/grid-batch-editing.html

    Looking forward to your reply.

    Regards,
    Eyup
    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017