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

Modal on "add new record"

3 Answers 270 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Marcus
Top achievements
Rank 1
Marcus asked on 01 Mar 2020, 01:57 AM

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.

 

3 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 04 Mar 2020, 08:46 AM

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.

 

0
Marcus
Top achievements
Rank 1
answered on 04 Mar 2020, 10:45 PM

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.

0
Accepted
Rumen
Telerik team
answered on 09 Mar 2020, 02:18 PM

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.
Tags
Grid
Asked by
Marcus
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Marcus
Top achievements
Rank 1
Share this question
or