• 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>
  • 相关阅读:
    手机端网页web开发要点
    js javascript:void(0) 真正含义
    牛客第二场 C.message(计算几何+二分)
    计算几何_三维凸包
    【kuangbin专题】计算几何_半平面交
    【kuangbin专题】计算几何_凸包
    【kuangbin专题】计算几何基础
    Codeforces 1058 D. Vasya and Triangle(分解因子)
    网络流模板
    2018 Multi-University Training Contest 6
  • 原文地址:https://www.cnblogs.com/zhangpengshou/p/1393129.html
Copyright © 2020-2023  润新知