- JScript code
<script language="javascript" type="text/javascript" src="@Url.Content("~/Scripts/ext-all.js")"></script> <link type="text/css" rel="Stylesheet" href="@Url.Content("~/Content/ext-all.css")" /> <script type="text/javascript"> Ext.Loader.setConfig({ enabled: true }); Ext.require([ 'Ext.grid.*', 'Ext.data.*', 'Ext.util.*', 'Ext.state.*', 'Ext.form.Panel' ]); Ext.onReady(function () { var isAdd = true; //默认是添加 Ext.define('NewContent', { extend: 'Ext.data.Mode', fields: [ 'NewsCategoryID', 'PublicDate', 'NewsMainTitle', 'NewsSubTitle', 'NewsSummary', 'NewsListImage', 'NewsContent', 'IsFocusNews', 'FocusNewsImage', 'IsAllowComment', 'IsPublicToMobileClient', 'NewsStatus', 'CreateDatetime' ] }); var NewContentStore = Ext.create('Ext.data.Store', { model: 'NewContent', proxy: { type: 'ajax', url: '@Url.Action("GetNewsContentList", "NewsContent")', reader: { type: 'json', root: "rows" } }, autoLoad: true }); var grid = Ext.create('Ext.grid.Panel', { store: NewContentStore, id: 'grid', layout: 'fit', columns: [ { header: 'ID', dataIndex: 'NewsCategoryID' }, { header: 'PublicDate', dataIndex: 'PublicDate', align: 'center' }, { header: 'NewsMainTitle', dataIndex: 'NewsMainTitle' }, { header: 'NewsSubTitle', dataIndex: 'NewsSubTitle', align: 'center' }, { header: 'NewsSummary', dataIndex: 'NewsSummary' }, { header: 'NewsListImage', dataIndex: 'NewsListImage', align: 'center' }, { header: 'NewsContent', dataIndex: 'NewsContent' }, { header: 'IsFocusNews', dataIndex: 'IsFocusNews', align: 'center' }, { header: 'FocusNewsImage', dataIndex: 'FocusNewsImage' }, { header: 'IsAllowComment', dataIndex: 'IsAllowComment', align: 'center' }, { header: 'IsPublicToMobileClient', dataIndex: 'IsPublicToMobileClient' }, { header: 'NewsStatus', dataIndex: 'NewsStatus', align: 'center' }, { header: 'CreateDatetime', dataIndex: 'CreateDatetime', align: 'center' } ], selModel: new Ext.create('Ext.selection.CheckboxModel'), viewConfig: { forceFit: true }, tbar: [ { text: 'new', handler: function () { isAdd = true; winForm.show(); } } , { text: 'Delete', handler: function () { } }, { text: 'Update', handler: function () { } } ] }); var NewsCateTabWin = Ext.widget('form', { items: [grid], renderTo: Ext.getBody() }); }); </script>