扩展Ext.Net.Window

时间:2013-08-09 08:36:26

标签: ext.net

我是stackoverflow和ext.net proggramming的新手,我想通过添加新属性扩展Ext.Net.Window,这是一个商店。 以下是我的代码:

C#代码:

public class ExtNetBaseWindowDB : Ext.Net.Window
{
  private Store FDBStore;

  protected override List<Ext.Net.ResourceItem> Resources
  { get {
    List<Ext.Net.ResourceItem> baseList = base.Resources;  
    baseList.Capacity += 1; 
    baseList.Add(new Ext.Net.ClientScriptItem(typeof(ExtNetBaseWindowDB), "Ext.Net_Lib.Scripts.ExtNetBaseWindowDB.js", "/Scripts/ExtNetBaseWindowDB.js"));
    return baseList; }
  }

  protected override void OnInit(EventArgs e)
  { FDBStore = new Store {
      ID = "store__",
      PageSize = 5,
      Model = { 
        new Model {
          ID="model__",
          Fields = {
            new ModelField("Field01", ModelFieldType.String),
            new ModelField("Field02", ModelFieldType.Float)  }
        } 
      }
    };
    base.OnInit(e);
  }

  [Browsable(false)]
  [EditorBrowsable(EditorBrowsableState.Never)]
  [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  [XmlIgnore]  
  [JsonIgnore]
  public override ConfigOptionsCollection ConfigOptions
  { get {
      ConfigOptionsCollection list = base.ConfigOptions; 
      list.Add("dbStore", new ConfigOption("dbStore", new SerializationOptions("dbStore",  JsonMode.Object), null, DBStore)); 
      return list;
    }
  }

  public Store DBStore
  { get { return FDBStore; } }
}

Javascript文件:

ExtNet.ExtNetBaseWindowDB = Ext.extend(Ext.window.Window, {
dbStore: null,
initComponent: function () {
    ExtNet.ExtNetBaseWindowDB.superclass.initComponent.call(this); },
initEvents: function () {
    ExtNet.ExtNetBaseWindowDB.superclass.initEvents.call(this); },  
onRender: function (ct, position) {
    ExtNet.ExtNetBaseWindowDB.superclass.onRender.call(this, ct, position); }
});

来自服务器的响应:

Ext.net.ResourceMgr.init({
    id: "ResourceManager1",
    aspForm: "form1",
    icons: ["PageSave", "Cancel"]
});

Ext.onReady(function () {
    Ext.create("Ext.window.Window", {
        hidden: false,
        renderTo: Ext.get("form1"),
        width: 200
});
Ext.create("ExtNet.ExtNetBaseWindowDB", {
    id: "wnd__",
    itemId: "item__",
    height: 300,
    hidden: false,
    renderTo: Ext.getBody(),
    width: 300,
    layout: "form",        
    title: "ExtNetBaseWindowDB",
    dbStore: new Ext.data.Store({
        model: ,
        storeId: "store_ExtNetBaseWindowDB",
        autoLoad: true,
        pageSize: 5,
        proxy: {
            type: 'memory'
        }
    })
});

请帮助我,我的窗户没有显示,我的代码中有什么问题吗? (如果我的工作表不好,我很抱歉)

1 个答案:

答案 0 :(得分:0)

商店无法以这种方式正确反序列化。

我可以建议以下解决方案。

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
    public class ExtNetBaseWindowDB : Ext.Net.Window
    {
        private Store FDBStore;

        public Store DBStore
        {
            get
            {
                return FDBStore;
            }
        }

        public string DBStoreProxy
        {
            get
            {
                if (this.DBStore == null)
                {
                    return "";
                }

                return this.DBStore.ToConfig();
            }
        }

        protected override void OnInit(EventArgs e)
        {
            FDBStore = new Store
            {
                ID = "Store1",
                PageSize = 5,
                Model = 
                { 
                    new Model 
                    {
                        ID = "Model1",
                        Fields = 
                        {
                            new ModelField("Field01", ModelFieldType.String),
                            new ModelField("Field02", ModelFieldType.Float)  
                        }
                    } 
                  }
            };

            base.OnInit(e);
        }

        public override ConfigOptionsCollection ConfigOptions
        {
            get
            {
                ConfigOptionsCollection list = base.ConfigOptions;
                list.Add("dbStore", new ConfigOption("dbStore", new SerializationOptions("dbStore", JsonMode.Raw), null, this.DBStoreProxy));
                return list;
            }
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!X.IsAjaxRequest)
        {
            this.Form.Controls.Add(new ExtNetBaseWindowDB());
        }
    }
</script>

<!DOCTYPE html>
<html>
<head runat="server">
    <title>Ext.NET v2 Example</title>
</head>
<body>
    <form runat="server">
        <ext:ResourceManager runat="server" />
    </form>
</body>
</html>