Raise Master Table View Add New Record Button in code behind

2 posts, 0 answers
  1. Cindy
    Cindy avatar
    1 posts
    Member since:
    Jun 2016

    Posted 02 Dec 2016 Link to this post

    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" />





  2. Eyup
    Eyup avatar
    4028 posts

    Posted 07 Dec 2016 Link to this post

    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.
Back to Top