• Ext生成GridView的CodeSmith模板


    <%-- 
    Name:
    <%= GetClassName(SourceTable) %>
    Author: sunfishlu
    Description: 
    --%>
    <%@ CodeTemplate Language="C#" TargetLanguage="JScript" Description="Generates a very simple business object." ResponseEncoding="UTF-8" %>
    <%@ Property Name="NameSpace" Type="String" Category="Text" Default="Sunfishlu." Description="The namespace to use for this class" %>
    <%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="Context" Description="Table that the object is based on." %>
    <%@ Assembly Name="SchemaExplorer" %>
    <%@ Assembly Name="System.Data" %>
    <%@ Import Namespace="SchemaExplorer" %>
    <%@ Import Namespace="System.Data" %>

    /**
     * @author sunfish
     
    */


    var storeMain 
    = new Ext.data.Store({
        proxy:
    new Ext.data.HttpProxy({
            url:
    '<%= GetUrlName(SourceTable) %>'
        }
    ),
        reader:
    new Ext.data.JsonReader({
            root:
    'data',
            id:
    '<%= SourceTable.PrimaryKey.MemberColumns[0].Name %>',
            totalProperty:
    'totalCount',
            fields:
            [
                
    <% for (int i=0; i < SourceTable.Columns.Count; ++i) %> <%=GetMemberVariableName(SourceTable.Columns[i])%><% if (i < SourceTable.Columns.Count - 1%>,<% }%><%}%>
            ]
        }
    ),
        remoteSort:
    true
    }
    );

    Ext.onReady(function()
    {
        Ext.BLANK_IMAGE_URL 
    = 'http://images.cnblogs.com/s.gif';
        Ext.QuickTips.init();
        var grid 
    = new Ext.grid.GridPanel({
            store:storeMain,
            columns:
            [
                
    new Ext.grid.RowNumberer(),
                
                
    <% for (int i = 0; i < SourceTable.Columns.Count; i++%>
                
    {header:"<%=GetHeaderName(SourceTable.Columns[i])%>",align:'center',sortable: true,dataIndex:<%=GetMemberVariableName(SourceTable.Columns[i])%>}<% if (i < SourceTable.Columns.Count - 1%>,<% } %>                
                
    <% }
     %>
            ],
            renderTo:
    'grid',
            viewConfig:
    {forceFit:true},        
            trackMouseOver:
    true,
            loadMask: 
    true,
            autoShow : 
    true,
            autoScroll: 
    true,
            loadMask:
    {msg:"数据加载中,请稍等"},
            bbar:
    new Ext.PagingToolbar({
                pageSize:
    20,
                store:storeMain,
                displayInfo:
    true,
                displayMsg:
    '当前显示 {0} - {1}条记录 /共 {2}条记录',
                emptyMsg:
    "没有数据"
            }
    )
        }
    );
        storeMain.load(
    {params:{start:0, limit:20,sort:'<%= SourceTable.PrimaryKey.MemberColumns[0].Name %>',dir:'desc'}});
    }
    );
    <script runat="template">
    // My functions here.
    public string GetClassName(TableSchema table)
    {
        
    if(table==null)
        
    {
            
    return null;
        }

        
    return table.Name + "Grid";
    }

    public string GetUrlName(TableSchema table)
    {
        
    if(table==null)
        
    {
            
    return null;
        }

        
    return table.Name + "Grid"+".aspx";
    }


    script script
    </script>
  • 相关阅读:
    解决多个window.onload冲突问题
    asp.net中img底部出现空白解決辦法
    学习WF起步
    ASP.NET后台注册javascript脚本方法
    WCF、Net remoting、Web service概念及区别
    WCF问答 WCF 与Web Service的区别
    C++深度探索系列:智能指针(Smart Pointer) [一] (转)
    ofstream和ifstream(详细2)转
    全面掌握const、volatile和mutable关键字(转)
    #define用法 收藏
  • 原文地址:https://www.cnblogs.com/zhangpengshou/p/1393129.html
Copyright © 2020-2023  润新知