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

RadToolButton RadButton ItemTemplate OnClientClicked not firing

2 Answers 22 Views
Button
This is a migrated thread and some comments may be shown as answers.
caesar
Top achievements
Rank 1
caesar asked on 11 Apr 2021, 05:39 PM
I'm trying to convert a RadToolButton into one with an ItemTemplate so I can use the <Icon> element for the modern css icon classes, but when I use the RadButton instead of the original RadToolButton, the client javascript function doesn't fire. How can I re-use the same javascript function for the RadButton inside the ItemTemplate as it is used in the RadToolButton?



<script>
function rtbClientDebts_ButtonClick(sender, args)
        {
            var button;
            button = args.get_item();
            ProcessGridCommand (button.get_commandName());
        }
</script>



<telerik:RadToolBar runat="server" ID="rtbClientDebts" Skin="Metro"  Width="100%" OnClientButtonClicked="rtbClientDebts_ButtonClick" EnableViewState="false">
        <Items>
 
            <%----- OLD BUTTON -----%>
            <telerik:RadToolBarButton runat="server" Text="Add"  CommandName="AddCreditor" SearchName="AddCreditor" Enabled="True" />
 
            <%----- NEW DESIRED BUTTON -----%>
            <telerik:RadToolBarButton>
                <ItemTemplate>
                    <telerik:RadButton runat="server" Text="Add" CommandName="AddCreditor" SearchName="AddCreditor" Enabled="True">
                        <Icon PrimaryIconCssClass="rbAdd" />
                    </telerik:RadButton>
                </ItemTemplate>
            </telerik:RadToolBarButton>
 
</Items>
</telerik:RadToolBar>

2 Answers, 1 is accepted

Sort by
0
caesar
Top achievements
Rank 1
answered on 11 Apr 2021, 05:41 PM
bump
0
Vessy
Telerik team
answered on 13 Apr 2021, 12:15 PM

Hi caesar,

The OnClientButtonClicked handler is attached to the buttons nested in the default template of RadToolbar. When a custom item template is used, you will need to handle the ClientClicked event of the controls added there instead:

        <script>
            function rtbClientDebts_ButtonClick(sender, args) {
                var button;
                button = args.get_item();
            }

            function templateButtonClick(button, args) {
                ProcessGridCommand(button.get_commandName());
            }
        </script>

        <telerik:RadToolBar runat="server" ID="rtbClientDebts" Skin="Metro" Width="100%" 
            OnClientButtonClicked="rtbClientDebts_ButtonClick" EnableViewState="false">
            <Items>

                <%----- OLD BUTTON -----%>
                <telerik:RadToolBarButton runat="server" Text="Add" CommandName="AddCreditor" SearchName="AddCreditor" Enabled="True" />

                <%----- NEW DESIRED BUTTON -----%>
                <telerik:RadToolBarButton>
                    <ItemTemplate>
                        <telerik:RadButton runat="server" Text="Add" CommandName="AddCreditor" SearchName="AddCreditor" 
                            Enabled="True" OnClientClicked="templateButtonClick" AutoPostBack="false">
                            <Icon PrimaryIconCssClass="rbAdd" />
                        </telerik:RadButton>
                    </ItemTemplate>
                </telerik:RadToolBarButton>
            </Items>
        </telerik:RadToolBar>

Regards,
Vessy
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Button
Asked by
caesar
Top achievements
Rank 1
Answers by
caesar
Top achievements
Rank 1
Vessy
Telerik team
Share this question
or