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

Raise Master Table View Add New Record Button in code behind

1 Answer 30 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Cindy asked on 02 Dec 2016, 04:48 PM

I'm hoping that someone can help me. I have a radgrid with a Add New Sales Opportunity button on the command bar at the top of the MasterTableView. When clicked the ItemCreated event is fired. I have a JavaScript alert that asks if the user wants to create another record after they have saved their first. I am using a HiddenField on the user control to send the response back to the server side. What I need to do is raise the ItemCreated event in the code behind to open a new add form if the user options to create a new record. 

Here's a snippet of how my grid is created in the user control:

<telerik:RadGrid  runat="server" ID="grdSalesOpportunity" CssClass="grdSalesOpportunityClass" AllowPaging="True" AllowCustomPaging="true" 
                AutoGenerateColumns="false" EnableLinqExpressions="false"
                AllowSorting="true" GridLines="Both" OnNeedDataSource="grdSalesOpportunity_NeedDataSource" CommandItemStyle-CssClass="swrap"
                NonExportingColumns="EditCommandColumn,DeleteColumn,AddNotes" ShowAllExportButtons="false"
                OnSortCommand="grdSalesOpportunity_SortCommand" OnPageSizeChanged="grdSalesOpportunity_PageSizeChanged"
                OnUpdateCommand="grdSalesOpportunity_UpdateCommand" OnInsertCommand="grdSalesOpportunity_InsertCommand"
                OnItemCommand="grdSalesOpportunity_ItemCommand" OnItemCreated="grdSalesOpportunity_ItemCreated" ShowExtraButtons="true">
                <ClientSettings Scrolling-AllowScroll="true" Scrolling-UseStaticHeaders="true"></ClientSettings>
                <GroupingSettings CaseSensitive="false" />
                <ExportSettings ExportOnlyData="True" IgnorePaging="True" OpenInNewWindow="True"
                    Pdf-PageWidth="350mm" Pdf-PageHeight="210mm" Pdf-PageLeftMargin="20mm" Pdf-PageRightMargin="20mm">

                <MasterTableView CommandItemDisplay="Top" DataKeyNames="SOID" AllowFilteringByColumn="true"
                    <CommandItemSettings ShowAddNewRecordButton="true" AddNewRecordText="Add New Sales Opportunity"
                        ShowExportToCsvButton="true" ShowExportToExcelButton="true" ShowExportToPdfButton="true"
                        ShowExportToWordButton="false" />





1 Answer, 1 is accepted

Sort by
Telerik team
answered on 07 Dec 2016, 11:17 AM
Hello Cindy,

You can fire grid commands using fireCommand method on client-side:

Or using FireCommandEvent method on server-side:

The built-in command for Add New Record is called InitInsert.

I hope this will prove helpful.

Telerik by Progress
Telerik UI for ASP.NET AJAX is ready for Visual Studio 2017 RC! Learn more.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question