简体   繁体   English

如何在选择事件中获取剑道菜单的父级和子级文本

[英]how to get parent and child text for the kendo menu in the select event

I am using kendo menu.For this I have parent level menu and for each I have sub items. 我正在使用剑道菜单。为此,我有父级菜单,每一个都有子项。 I want to get the parent item text and sub item text in the select event. 我想在select事件中获取父项文本和子项文本。

To get the parent text,I used "open" function,by this I am able to get parent text,but I want this in select event. 要获取父文本,我使用了“打开”功能,因此我可以获取父文本,但是我想在select事件中使用它。

$("#menu").kendoMenu({
       open: function onOpen(e) {
              parentText = $(e.item).children(".k-link").text();
            },
});

If you only have parent and child (two levels menu) you can use as selector for the parent the CSS class k-state-active This is a CSS class to add to each of the ancestors of the selected option. 如果只有父级和子级(两级菜单),则可以用作父级的选择器CSS类k-state-active这是一个CSS类,可添加到所选选项的每个祖先中。

Your code would be: 您的代码为:

select: function (e) {
    var me = e.item;
    console.log("me", $(child).find(".k-link").text());
    var father = $(".k-state-active", this.element);
    console.log("father", father.text().trim());
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何对Kendo pdfExport事件进行编程以导出父行和子行 - How to Program the Kendo pdfExport event to export parent and child rows 如何在kendo TreeList中选择父节点时选择所有子节点? javascript - How to select all child nodes on selecting parent in kendo TreeList? javascript 拖动父项,但子项上的文本为 select? - Drag parent, but select text on child? 如何停止从子 select 的父 div 传播事件 - How to stop propagating event from parent div in child select 当父节点被选中时,如何触发Kendo TreeView中子节点的onCheck事件 - How to trigger the onCheck event for child nodes in Kendo TreeView, when parent is checked Kendo ASP.Net MVC Datagrid如何在子行中获取父行ID - Kendo ASP.Net MVC Datagrid how to get Parent Row Id in child rows Kendo 网格 - 如何在添加/编辑子行(详细网格)时访问父行模型 - Kendo grid - How to get access to Parent row model on add / edit child row (detail grid) 如果单击 select 菜单中的第一个元素,如何让事件侦听器不被忽略 - how to get event listener not to ignore if the first element in the select menu is clicked 如果我拖放子节点,如何获取父节点的文本? - how to get the text of parent node if i drag drop child node? 如何仅从父标签而不是从子标签获取文本 - How to get the text only from parent tag and not from the child tag
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM