zoukankan      html  css  js  c++  java
  • Ext.Net动态加载菜单执行事件

    下面是今天实际例子,动态加载菜单的代码。非常好用哦

     下面有两种方式添加事件:

    MenuItem mi = new Ext.Net.MenuItem(entity.FullName)
                    {
                        IconCls = iconCls,
                        Menu =
                            {
                                new Ext.Net.Menu
                                {
                                    Items = {
                                      new Ext.Net.MenuItem { IconCls="x-loading-indicator", Text="Loading...", CanActivate=false, HideOnClick=false }
                                    },
                                    TagString = entity.FullName,
                                    Loader = new ComponentLoader
                                    {
                                        Mode = LoadMode.Component,
                                        DirectMethod = "#{DirectMethods}.Items",//加载方法
                                        RemoveAll = true,
                                        Params = {//设置调用事件时给的参数
                                            new Ext.Net.Parameter("tag", "this.tag", ParameterMode.Raw),
                                            new Ext.Net.Parameter("id", entity.Id.ToString(), ParameterMode.Raw)
                                        }
                                    }
                                }

                            }
                         //第一种方法,在初始时给listeners事件初始
                        // ,Listeners =
                        //{
                        //    Click = { Handler = "loadMenuExample('" + this.UserInfo.GetUserParameter(entity.NavigateUrl) + "','" + entity.Id + "','" + entity.FullName + "','" + iconCls + "');" }
                        //}
                    };
                    var childList = this.UserModuleList.Where(child => child.ParentId != null && child.ParentId.ToString().Equals(entity.Id.ToString())).OrderBy(child => child.SortCode);
                    if (childList.Count() <= 0) //是否有子菜单,如果有不本级菜单不加载事件. 第二种方式:在创建完menuitem时再追加进去事件
                        mi.Listeners.Click.Handler = "loadMenuExample('" + this.UserInfo.GetUserParameter(entity.NavigateUrl) + "','" + entity.Id + "','" + entity.FullName + "','" + iconCls + "');" ;
                    items.Add(mi);

    调用的Items方法使用:

    [DirectMethod]
            public new string Items(Dictionary<string, string> parameters)
            {

                //System.Threading.Thread.Sleep(1500); //emulate net delay
                string tag = parameters["tag"];
                string id = parameters["id"];

            }

  • 相关阅读:
    nodejs pm2使用
    react生命周期
    It's a start!
    关于react-native报错: Invariant Violation: WebView has been removed from React Native. It can ....
    react-native 页面使用WebView布满整个页面,导航栏不显示问题
    两个函数执行顺序,异步问题处理(已解决)
    react-native webView乱码问题
    react-native 多页面之间传值
    时间戳转换为时间日期格式
    React Native返回刷新页面(this.props.navigation.goBack())
  • 原文地址:https://www.cnblogs.com/spring_wang/p/3080917.html
Copyright © 2011-2022 走看看