How to show Kendo Grid's columnMenu using script

百般思念 提交于 2019-12-21 14:06:23

问题


The Kendo Grid has a really nice column context menu (aka: columnMenu) which you can access by right clicking on each column header. The menu is enabled by setting the field in the Kendo Grid to:

columnMenu: true

When the columnMenu is enabled, it displays the columns in the grid and allows you to show/hide columns, sort, and filter on them. However, we have a requirement to move this column menu outside of the grid and tie it to a button. So when the user clicks on a button, the column menu will appear. Is there a way to invoke this via javascript?

This request is similar to one made by Michiel (March 5, 2012). However, in that particular case, it was a request for the contextMenu for a different product, the Telerik MVC Grid. The URL for Michiel's question is below as a reference: http://www.telerik.com/community/forums/aspnet-mvc/grid/how-to-show-column-context-menu-using-script.aspx


回答1:


It is as simple as triggering the click event of the column:

$("#grid .k-header-column-menu:first").click();

Here is a working demo: http://jsbin.com/ihivif/2/edit



来源:https://stackoverflow.com/questions/13637475/how-to-show-kendo-grids-columnmenu-using-script

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!