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

Add toolbar.ClientTemplate without overriding previous toolbars

1 Answer 1194 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Edward
Top achievements
Rank 1
Edward asked on 14 May 2019, 09:16 PM

toolbar.ClientTemplat(string) seems to override all previous toolbar items.

So:

 

.ToolBar(toolbar => {
                        toolbar.Create(); /*toolbar.Save();*/
                        toolbar.Custom().Text("export").IconClass("k-icon k-i-table").HtmlAttributes(new { onclick = "approval_grid_export()" });

                        toolbar.ClientTemplate("etc");

                    })

seems to destroy the toolbar.Create() and toolbar.Custom().

Is there way to just add the ClientTemplate()?

1 Answer, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 17 May 2019, 01:46 PM
Hi Edward,

When a template is used the grid ignores the rest of the toolbar configuration and simply displays the content of the custom template within the element of the toolbar.

Nevertheless, as a workaround I can suggest you to simply include the built in commands within the custom toolbar.

e.g.

toolbar.ClientTemplate(@"
<a class='k-button' onclick='customCommand()'>Button Here</a>
<a role='button' class='k-button k-button-icontext k-grid-excel' href='#'><span class='k-icon k-i-file-excel'></span>Export to Excel</a>
<a role='button' class='k-button k-button-icontext k-grid-pdf' href='#'><span class='k-icon k-i-file-pdf'></span>Export to PDF</a>
<a role='button' class='k-button k-button-icontext k-grid-add' href='#'><span class='k-icon k-i-plus'></span>Add new record</a>
<a role='button' class='k-button k-button-icontext k-grid-save-changes' href='#'><span class='k-icon k-i-check'></span>Save changes</a>
<a role='button' class='k-button k-button-icontext k-grid-cancel-changes' href='#'><span class='k-icon k-i-cancel'></span>Cancel changes</a>
"));


Regards,
Georgi
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
serge
Top achievements
Rank 2
Bronze
Iron
Iron
commented on 04 Aug 2023, 12:20 AM

"it simply ignores..." Why did YOU( Telerik) build it like this? This behavior sucks.
Aleksandar
Telerik team
commented on 08 Aug 2023, 01:04 PM

Hi Serge, 

This is indeed a valid point. I have added a Feature Request on your behalf to expose such a configuration. Feel free to add anything I might have missed to the item. 

Until the item is implemented the approach to customize the Grid's ToolBar is still the one suggested in the answer to the initial question and as demonstrated in the Grid's ToolBar Template Demo.

Tags
Grid
Asked by
Edward
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Share this question
or