如何使用脚本显示Kendo Grid的columnMenu [英] How to show Kendo Grid's columnMenu using script

查看:173
本文介绍了如何使用脚本显示Kendo Grid的columnMenu的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Kendo Grid有一个非常不错的列上下文菜单(又名:columnMenu),您可以通过右键单击每个列标题来访问.通过将Kendo网格中的字段设置为以下内容来启用菜单:

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:是

columnMenu: true

启用columnMenu后,它将显示网格中的列,并允许您显示/隐藏列,对其进行排序和过滤.但是,我们需要将此列菜单移至网格之外并将其绑定到按钮.因此,当用户单击按钮时,将出现列菜单.有没有办法通过javascript来调用它?

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?

此请求类似于Michiel的请求(2012年3月5日).但是,在特定情况下,这是对另一个产品Telerik MVC Grid的contextMenu的请求.以下是有关Michiel的问题的URL作为参考:

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

推荐答案

就像触发列的click事件一样简单:

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

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

这是一个有效的演示: http://jsbin.com/ihivif/2/edit

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

这篇关于如何使用脚本显示Kendo Grid的columnMenu的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆