Modal on "add new record"

4 posts, 1 answers
  1. Marcus
    Marcus avatar
    8 posts
    Member since:
    Aug 2019

    Posted 29 Feb Link to this post

    Hello all,

    I'm trying to figure out how to wire up the standard "Add new record" command button to a modal popup for adding new records.
    Not sure if this makes any difference, but the grid is in batch edit mode.

    Thx in advance for help and/or pointers!

    M.

     

  2. Rumen
    Admin
    Rumen avatar
    14391 posts

    Posted 04 Mar Link to this post

    Hi Marcus,

    You can check out the following demo which shows integration with a modal RadWindow - https://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandwindow/defaultcs.aspx?product=window.

    Regards,
    Rumen
    Progress Telerik

    Get quickly onboarded and successful with UI for ASP.NET AJAX with the Virtual Classroom technical trainings, available to all active customers. Learn More.

     

  3. Marcus
    Marcus avatar
    8 posts
    Member since:
    Aug 2019

    Posted 04 Mar Link to this post

    Hi Rumen,

    thx for your comment, but that's not what I'm looking for. I probably stated my question wrong - let me rephrase: I would like to keep the inline batch edit functionality for editing, but have a modal popup for insert operations.

    Possible?

    Thx in advance - M.

  4. Answer
    Rumen
    Admin
    Rumen avatar
    14391 posts

    Posted 09 Mar Link to this post

    Hi Marcus,

    I am afraid batch editing does not fire any command when you add a new record and this functionality is not supported built-in. Nevertheless, a possible solution is to access the Add New Record button and override the onclick function. Please check out the following code snippet and use it as a base to proceed with your implementation:

    C#:

    protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridCommandItem)
        {
            GridCommandItem commandItem = e.Item as GridCommandItem;
            Button button = commandItem.FindControl("AddNewRecordButton") as Button;
            button.OnClientClick = "addNewRecords(); return false";
        }
    }



    JavaScript:

    <script type="text/javascript">
        function addNewRecords() {
             
            //manually fire add new records and execute your logic to show popup
     
            var grid = $find('<%= RadGrid1.ClientID %>');
            grid.get_batchEditingManager().addNewRecord(grid.get_masterTableView().get_id());
        }
    </script>



    I hope this information helps.

     

    Regards,
    Rumen
    Progress Telerik

    Get quickly onboarded and successful with UI for ASP.NET AJAX with the Virtual Classroom technical trainings, available to all active customers. Learn More.
Back to Top