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.
Get quickly onboarded and successful with UI for ASP.NET AJAX with the Virtual Classroom technical trainings, available to all active customers.Learn More.
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#:
protectedvoidRadGrid1_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:
<scripttype="text/javascript">functionaddNewRecords() {
//manually fire add new records and execute your logic to show popupvar 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.