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

Adding CommandItemTemplate command and keeping the defaults

10 Answers 1448 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Phil
Top achievements
Rank 2
Phil asked on 09 Apr 2009, 12:57 PM
Hi:
I am adding an additional command via CommandItemTemplate and I would like to keep the defaults of Add and refresh.
<CommandItemTemplate> 
    <asp:LinkButton ID="radWindowAdd" runat="server" CommandName="MultiAdd" Text="Multi-Add" /> 
</CommandItemTemplate> 
 
But adding the above, seems to eliminate the default Add and Refresh.
Phil

10 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 13 Apr 2009, 11:34 AM

Hello Phil,

Indeed when you define a custom command item template the default buttons from the command item will be removed. However, you can include the default 'Add new record' and 'Refresh' buttons inside the command item template of the grid (with their CommandName values InitInsert and Rebind respectively) as explained in this documentation topic.

Kind regards,

Sebastian
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Phil
Top achievements
Rank 2
answered on 14 Apr 2009, 11:37 PM
I did that right after I posted this, but as I recall the icon does not come back.
Phil
0
Sebastian
Telerik team
answered on 15 Apr 2009, 08:01 AM
Hello Phil,

You can copy the same icons and add them as image buttons inside the command item template if you would like to have exactly the same command item appearance.

Best regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Accepted
Brian Duckworth
Top achievements
Rank 1
answered on 19 Apr 2009, 05:28 AM
Phil,

You can get your default button/images back by using specific styles:

      <CommandItemTemplate>
        <asp:Button ID="btnAdd" runat="server" CommandName="InitInsert" CssClass="rgAdd" />
        <asp:Button ID="btnRefresh" runat="server" CommandName="Rebind" CssClass="rgRefresh" />
      </CommandItemTemplate>

These styles will display the default skin icons for any skin you may be using.

Cheers,
Thierry
0
Scott Hannon
Top achievements
Rank 1
answered on 15 Sep 2011, 02:38 PM
I know this is an old thread but in case someone stumbles upon this solution and also needs to know how to use commanditemtemplate and use the default export buttons, one can use them similarly as Brian showed in his solution like so:

<CommandItemTemplate>
    <div style="display:inline-block; width:100%;">
        <div style="float:left;">
            <!--my custom button-->
    <telerik:RadToolBar ID="RadToolBar1" OnButtonClick="RadToolBar1_ButtonClick" runat="server"
        Height="30px" OnClientButtonClicking="clientbuttonclick">
        <Items>
            <telerik:RadToolBarButton Text="Delete selected items" CommandName="DeleteSelected"
                ImageUrl="~/images/Delete.gif">
            </telerik:RadToolBarButton>
        </Items>
    </telerik:RadToolBar>
    <!--end custom button-->
    </div>
    <div style="float:right;">
        <!--add default buttons back-->
    Export: 
    <asp:Button ID="ExportToExcelButton" runat="server" CommandName="ExportToExcel" CssClass="rgExpXLS"/>
      
    <asp:Button ID="ExportToWordButton" runat="server" CommandName="ExportToWord" CssClass="rgExpDOC" />
      
    <asp:Button ID="ExportToPdfButton" runat="server" CommandName="ExportToPdf" CssClass="rgExpPDF" />
      
    <asp:Button ID="ExportToCsvButton" runat="server" CommandName="ExportToCsv" CssClass="rgExpCSV" />
        <!--end of add-->
    </div>
    </div>
</CommandItemTemplate>
0
Stephen
Top achievements
Rank 1
answered on 16 Jan 2017, 07:24 PM

Hello,

I am running into an issue where I have added a button to the commandItemTemplate but it will not fire the OnClick event when RenderMode="Mobile". However if RenderMode is anything else (in this case lightweight) the button will fire the event.

Is there a property of the Mobile render mode that prevents commandItemTemplate buttons from being fired?

here is the code:

<telerik:RadGrid ID="rdFileClosingsReport" runat="server" OnNeedDataSource="rdFileClosingsReport_NeedDataSource" OnItemCommand="rdFileClosingsReport_ItemCommand" OnItemDataBound="rdFileClosingsReport_ItemDataBound"
                           AllowFilteringByColumn="True" GroupingSettings-CaseSensitive="false"
                           ValidationSettings-ValidationGroup="gridSeller" PageSize="10" AllowPaging="true" ClientSettings-Selecting-AllowRowSelect="true" AllowSorting="true" Skin="Bootstrap" GridLines="None"
                           ExportSettings-IgnorePaging="true" ClientSettings-EnablePostBackOnRowClick="true" RenderMode="Lightweight">
                           <PagerStyle Mode="NumericPages" />
                           <MasterTableView AutoGenerateColumns="false" DataKeyNames="CCMasterID" ShowHeader="true" CommandItemDisplay="Top">
                               <CommandItemTemplate>
                                   <asp:Button runat="server" ID="btnSetAllClosingsAsBilled" OnClick="btnSetAllClosingsAsBilled_Click" Text="Bill All" CssClass="gridBtn pull-right" />
                                   <asp:Button ID="Button1" runat="server" Text=" " CssClass="rgExpCSV" CommandName="ExportToCSV" />
                               </CommandItemTemplate>
                               <CommandItemSettings ShowExportToExcelButton="true" ShowAddNewRecordButton="false" ShowRefreshButton="false" />
                               <Columns>
                                   <telerik:GridBoundColumn DataField="CCMasterID" UniqueName="CCMASTERID"></telerik:GridBoundColumn>
                                   <telerik:GridBoundColumn DataField="FILENO" UniqueName="FILENO" HeaderText="File Number"></telerik:GridBoundColumn>
                                   <telerik:GridDateTimeColumn DataField="ORDMADEDAT" HeaderText="Order Made Date" UniqueName="ORDMADEDAT" SortExpression="ORDMADEDAT" PickerType="DatePicker" DataFormatString="{0:MM/dd/yyyy}"></telerik:GridDateTimeColumn>
                                   <telerik:GridBoundColumn DataField="SETLAGENT" UniqueName="SETLAGENT" HeaderText="Settlement Agent"></telerik:GridBoundColumn>
                                   <telerik:GridBoundColumn DataField="SORDTAKENB" UniqueName="SORDTAKENB" HeaderText="Order Taken By"></telerik:GridBoundColumn>
                                   <telerik:GridBoundColumn DataField="LOANAMOUNT" UniqueName="LOANAMOUNT" HeaderText="Loan Amount"></telerik:GridBoundColumn>
                                   <telerik:GridBoundColumn DataField="SALESPRICE" UniqueName="Userid" HeaderText="Sales Price"></telerik:GridBoundColumn>
                                   <telerik:GridBoundColumn DataField="isBilledToClientAtPerFileRate" UniqueName="isBilledToClientAtPerFileRate" Visible="false"></telerik:GridBoundColumn>
                                   <telerik:GridDateTimeColumn DataField="CLOSEDATE" UniqueName="CLOSEDATE" HeaderText="Closing Date" SortExpression="CLOSEDATE" PickerType="DatePicker" DataFormatString="{0:MM/dd/yyyy}"></telerik:GridDateTimeColumn>
                                   <telerik:GridBoundColumn DataField="FileStatus" UniqueName="FileStatus" HeaderText="Status"></telerik:GridBoundColumn>
                                   <telerik:GridButtonColumn UniqueName="BilledButton" ButtonType="ImageButton" ImageUrl="Content/images/dollar-black-circle-icon-28.png" ButtonCssClass="downloadimage" CommandName="ToggleFileBilled" HeaderText="File Billed" DataTextFormatString="">
                                   </telerik:GridButtonColumn>
                               </Columns>
                               <NoRecordsTemplate>
                                   <div>
                                       There are no records to display
                                   </div>
                               </NoRecordsTemplate>
                           </MasterTableView>
                       </telerik:RadGrid>

 

 

As you can see for now i have the RenderMode as Lighweight. 

 

Thank You,

-SC

0
Konstantin Dikov
Telerik team
answered on 19 Jan 2017, 12:30 PM
Hi Steve,

We have logged issue for this. Nevertheless, I have tested with our latest version and using a RadButton instead fires the event correctly:
<CommandItemTemplate>
    <telerik:RadButton runat="server" ID="RadButton1" Text="test" OnClick="RadButton1_Click"></telerik:RadButton>

Can you please try with a RadButton and see if this will resolve the problem on your end.


Regards,
Konstantin Dikov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Stephen
Top achievements
Rank 1
answered on 23 Jan 2017, 07:52 PM

Thank You,

Looks like this is what i needed to do.

-Stephen

0
Mark
Top achievements
Rank 1
answered on 29 Mar 2017, 03:36 PM

I have the exact problem as Stephen (button events and OnItemCommand in the CommandItemTemplate do not fire when redermode = mobile) and tried the fix recommended by Konstantin. It does not work. Are there any other suggestions and is there a fix in the making?

 

Regards,

Mark

 

0
Konstantin Dikov
Telerik team
answered on 03 Apr 2017, 08:56 AM
Hi Mark,

I have created a public item where you could follow its progress. Additionally, I have increased the priority of the issue:
Please give a vote for the public item, so you could further increase its priority.


Best Regards,
Konstantin Dikov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Phil
Top achievements
Rank 2
Answers by
Sebastian
Telerik team
Phil
Top achievements
Rank 2
Brian Duckworth
Top achievements
Rank 1
Scott Hannon
Top achievements
Rank 1
Stephen
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Mark
Top achievements
Rank 1
Share this question
or