⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 templatescript.cs

📁 经典编程900例(C语言),主要是C基础知识
💻 CS
字号:
using System;
using System.DHTML;
using Ext;

namespace SampleScripts.core {
    public class TemplateScript {
    	private Panel _p1;
		private Panel _p2;

        public static void main(Dictionary args) {
			ExtClass.onReady(new AnonymousDelegate(delegate() { new TemplateScript().init(); }));
        }

		public void init()
		{
			Dictionary data = new Dictionary(
				"name", "Jack Slocum",
				"company", "Ext JS, LLC",
				"address", "4 Red Bulls Drive",
				"city", "Cleveland",
				"state", "Ohio",
				"zip", "44102",
				"kids", new object[]
				        	{
				        		new Dictionary("name", "Sara Grace", "age", 3),
				        		new Dictionary("name", "Zachary", "age", 2),
				        		new Dictionary("name", "John James", "age", 0),
				        	}
				);

			_p1 = new Panel(new PanelConfig()
            	.title("Basic Template")
            	.width(300)
            	.html("<p><i>Apply the template to see results here</i></p>")
				.tbar(new object[]
                        {
                            new Ext.Toolbar.ButtonConfig()
                                .text("Apply Template")
                                .handler(new AnonymousDelegate(delegate
                                    {
                                        Template tpl = new Template(
                                            @"<p>Name: {name}</p>
											<p>Company: {company}</p>
											<p>Location: {city}, {state}</p>");
                                        Element body = (Element) Type.GetField(_p1, "body");
                                        tpl.overwrite(body, data);
                                        body.highlight("#c3daf9", new Dictionary("block", true));
                                    }))
								.ToDictionary()
                        })
            	.renderTo(Document.Body)
            	.ToDictionary());

            _p2 = new Panel(new PanelConfig()
                .title("XTemplate")
                .width(300)
                .html("<p><i>Apply the template to see results here</i></p>")
				.tbar(new object[]
                        {
                            new Ext.Toolbar.ButtonConfig()
                                .text("Apply Template")
			                    .handler(new AnonymousDelegate(delegate 
									{
										XTemplate tpl = new XTemplate(
											@"<p>Name: {name}</p>
											<p>Company: {company}</p>
											<p>Location: {city}, {state}</p>
											<p>Kids: 
											<tpl for=""kids"" if=""name=='Jack Slocum'"">
												<tpl if=""age &gt; 1""><p>{#}. {parent.name}'s kid - {name}</p></tpl>
											</tpl></p>");

										Element body = (Element)Type.GetField(_p2, "body");
										tpl.overwrite(body, data);
										body.highlight("#c3daf9", new Dictionary("block", true));
                                    }))
								.ToDictionary()
                        })
            	.renderTo(Document.Body)
            	.ToDictionary());
		}
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -