ExtJS 4 - 获取菜单的选定项目

时间:2022-10-16 22:57:49

I am building a web application where the user can select choices off of a menu. So far, I've been handling the menu item selection quite well. I can assign a selection listener to my menu item and do actions accordingly.

我正在构建一个Web应用程序,用户可以从菜单中选择选项。到目前为止,我一直在很好地处理菜单项选择。我可以为菜单项分配一个选择监听器并相应地执行操作。

However, before I can do anything based off of the selection, I have to make the user log in first. The flow would be as such:

但是,在我根据选择做任何事情之前,我必须先让用户登录。流程将是这样的:

Menu Item Selection --> Log In --> Action based off of the menu selection

My main issue now is I can't seem to get the selected item from the menu. I've checked the Sencha Docs for this and the Menu doesn't seem to have a getSelection() method in it. I need to be able to fetch the selected item in my menu.

我现在的主要问题是我似乎无法从菜单中获取所选项目。我已经检查了Sencha Docs,而Menu似乎没有getSelection()方法。我需要能够在菜单中获取所选项目。

Does anyone know a work around for this scenario?

有没有人知道这种情况的解决方案?

1 个解决方案

#1


0  

I actually just used Cookies to store the selected item.

我实际上只是使用Cookie来存储所选项目。

During my onClick function, I did the following:

在我的onClick函数中,我做了以下事情:

Ext.util.Cookies.set("key", value);

and then to fetch it later on I used

然后在我使用的时候取出它

var key = Ext.util.Cookies.get("key");

This works for ExtJS 4.2, as for ExtJS 5 onwards, I think using Ext.data.Session might be more desirable.

这适用于ExtJS 4.2,对于ExtJS 5以上,我认为使用Ext.data.Session可能更合适。

#1


0  

I actually just used Cookies to store the selected item.

我实际上只是使用Cookie来存储所选项目。

During my onClick function, I did the following:

在我的onClick函数中,我做了以下事情:

Ext.util.Cookies.set("key", value);

and then to fetch it later on I used

然后在我使用的时候取出它

var key = Ext.util.Cookies.get("key");

This works for ExtJS 4.2, as for ExtJS 5 onwards, I think using Ext.data.Session might be more desirable.

这适用于ExtJS 4.2,对于ExtJS 5以上,我认为使用Ext.data.Session可能更合适。