grid.setOptions error "Custom commands should have name specified"

1 Answer 121 Views
Grid
Morten
Top achievements
Rank 2
Iron
Iron
Veteran
Morten asked on 15 Feb 2022, 02:01 PM

Hi Support

Back in 2016, I asked the same question: https://www.telerik.com/forums/grid-setoptions-error-custom-commands-should-have-name-specified (but must have solvedtheissueanotherway).

Now, I have the same requirement (to persist the state of a grid: https://demos.telerik.com/kendo-ui/grid/persist-state)

Using Kendo UI v2021.3.1216, I still get the same error when I call grid.setOptions: "Custom commands should have name specified".

I have changed the "Persist state" grid demo (https://demos.telerik.com/kendo-ui/grid/persist-state) by just adding the following code to the grid setup:

toolbar: [
  { template: kendo.template($("#toolbar-template").html()) }
],

The toolbar template is simply:

    <script id="toolbar-template" type="text/x-kendo-template">
        x
    </script>

The dojo: https://dojo.telerik.com/@mortenma71/EgoYILeS/2

It seems that the persisting grid state with a toolbar template is not possible. The saved options has an empty toolbar (see screenshot)

Could you help?

Thanks.

/Morten




                                 
Morten
Top achievements
Rank 2
Iron
Iron
Veteran
commented on 16 Feb 2022, 09:12 AM

turns out:

This works:

$("#grid").kendoGrid({
    toolbar: "toolbar inline",
    ...

This does not work:

    <script id="toolbar-template" type="text/x-kendo-template">
        toolbar from template
    </script>

$("#grid").kendoGrid({
    toolbar: [ { template: window.kendo.template($("#toolbar-template").html()) } ],
    ...

1 Answer, 1 is accepted

Sort by
0
Georgi Denchev
Telerik team
answered on 18 Feb 2022, 09:42 AM

Hello, Morten,

Thank you for the provided details and Dojo!

We've added a Knowledge Base article which showcases how you can Persist the Grid state with all of the functions included.

https://docs.telerik.com/kendo-ui/knowledge-base/grid-persist-state-with-functions 

This will allow you to use an external template alongside with kendo.template() and setOptions.

Updated Dojo:

https://dojo.telerik.com/@gdenchev/apUlItop 

Best Regards,
Georgi Denchev
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
Grid
Asked by
Morten
Top achievements
Rank 2
Iron
Iron
Veteran
Answers by
Georgi Denchev
Telerik team
Share this question
or