/****组件****/
//文章网格
Ext.ArticleGrid=Ext.extend(Ext.grid.GridPanel ,{
xtype:'grid',
id:'show-btn',
title:'所有文章',
width:'100%',
height:500,
columns:[
{
header:'编号',
sortable:true,
resizable:true,
dataIndex:'id',
width:'10%'
},
{
header:'标题',
sortable:true,
resizable:true,
dataIndex:'title',
width:'70%'
},
{
header:'作者',
sortable:true,
resizable:true,
dataIndex:'updateTime',
width:'10%'
}
,
{
header:'更新时间',
sortable:true,
resizable:true,
dataIndex:'updateTime',
width:'10%'
}
],
bbar: new Ext.PagingToolbar({
store: articleStore,
displayInfo: true,
pageSize: 5,
prependButtons: true
}),
listeners:{
"rowdblclick":queryArticleForUpdateEvent
}, initComponent: function(){
Ext.ArticleGrid.superclass.initComponent.call(this);
}
})
Ext.AddArticleForm=Ext.extend(Ext.form.FormPanel ,{
xtype:"form",
title:'',
labelWidth:100,
labelAlign:"left",
layout:"form",
width:'100%',
heigth:'100%',
bodyStyle:'padding:5px,5px,5px,5px;',
initComponent: function(){
this.items=[
{
name:'article.title',
xtype:"textfield",
fieldLabel:"标题",
anchor:"90%"
},
{
name:'article.keyWords',
xtype:"textfield",
fieldLabel:"关键字",
anchor:"70%"
},
{
hiddenName:'article.classify.id',
xtype:"combo",
triggerAction:"all",
fieldLabel:"分类",
loadingText:"正在加载数据...",
anchor:"50%",
store : articleClsStore,
valueField : "id",
displayField : "name",
selectOnFocus:true
},
{
hiddenName:'article.special.id',
xtype:"combo",
triggerAction:"all",
fieldLabel:"专题",
loadingText:"正在加载数据...",
anchor:"50%",
store : articleSpcStore,
valueField : "id",
displayField : "name",
selectOnFocus:true
},{
hiddenName:'article.addTime',
xtype:"datefield",
fieldLabel:"有效时间",
anchor:"50%",
format: 'Y-m-d H:i:s'
},{
name:'article.mainContent',
xtype:"textarea",
anchor:"90%",
fieldLabel:"内容",
height:600,
width:450
},{
xtype:"button",
text:"保 存",
listeners:{
'click':addArticleEvent
}
}
],
Ext.AddArticleForm.superclass.initComponent.call(this);
}
})
Ext.UpdateArticleForm=Ext.extend(Ext.form.FormPanel ,{
xtype:"form",
title:'',
labelWidth:100,
labelAlign:"left",
layout:"form",
width:'100%',
heigth:'100%',
bodyStyle:'padding:5px,5px,5px,5px;',
initComponent: function(){
this.items=[
{
name:'article.id',
xtype:"hidden",
anchor:"90%"
},
{
name:'article.title',
xtype:"textfield",
fieldLabel:"标题",
anchor:"90%"
},
{
name:'article.keyWords',
xtype:"textfield",
fieldLabel:"关键字",
anchor:"70%"
},
{
hiddenName:'article.classify.id',
xtype:"combo",
triggerAction:"all",
fieldLabel:"分类",
loadingText:"正在加载数据...",
anchor:"50%",
store : articleClsStore,
valueField : "id",
displayField : "name",
selectOnFocus:true
},
{
hiddenName:'article.special.id',
xtype:"combo",
triggerAction:"all",
fieldLabel:"专题",
loadingText:"正在加载数据...",
anchor:"50%",
store : articleSpcStore,
valueField : "id",
displayField : "name",
selectOnFocus:true
},{
hiddenName:'article.addTime',
xtype:"datefield",
fieldLabel:"有效时间",
anchor:"50%",
format: 'Y-m-d H:i:s'
},{
name:'article.mainContent',
xtype:"textarea",
anchor:"90%",
fieldLabel:"内容",
height:600,
width:450
},{
xtype:"button",
text:"我的按钮",
listeners:{
'click':addArticleEvent
}
}
],
Ext.UpdateArticleForm.superclass.initComponent.call(this);
}
})
/****数据源****/
var articleStore = new Ext.data.Store({
reader:new Ext.data.JsonReader({
totalRecords:'totalCount',//分页时需要的参数
root:'root',//json格式的根节点
fields:[ //在数据库中映射的字段名
{name:'id',type:'int'},
{name:'title',type:'String'},
{name:'updateTime', type: 'date', dateFormat: 'n/j h:ia'}
]
}),
//发送请求得到以上数据
proxy:new Ext.data.HttpProxy({
url:webRoot + '/manager/Article)list'
}) }); var articleClsStore = new Ext.data.Store({
reader:new Ext.data.JsonReader({
totalRecords:'totalCount',//分页时需要的参数
root:'root',//json格式的根节点
fields:[ //在数据库中映射的字段名
{name:'id',type:'int'},
{name:'name',type:'String'}
]
}),
//发送请求得到以上数据
proxy:new Ext.data.HttpProxy({
url:webRoot + '/manager/ArticleClassify)list'
}) }); var articleSpcStore = new Ext.data.Store({
reader:new Ext.data.JsonReader({
totalRecords:'totalCount',
root:'root',
fields:[
{name:'id',type:'int'},
{name:'name',type:'String'}
]
}),
proxy:new Ext.data.HttpProxy({
url:webRoot + '/manager/ArticleSpecail)list'
})
});/****初始化****/
var articleGrid = new Ext.ArticleGrid({});
var articleWin ;
var articleForm ;
articleStore.load();
articleGrid.store = articleStore;
articleGrid.doLayout();
/****事件****/ function addArticleEvent(){
articleForm.getForm().submit({
waitMsg: '正在提交数据...',
waitTitle: '提示',
method: 'post',
url:webRoot + '/manager/Article)add',
success: function(form, action) {
var flag=action.result.success;
Ext.Msg.alert('提示',flag);
if(flag == '提交成功'){
Ext.Msg.alert('提示',flag);
addArticleForm.getForm().reset();
}
},
failure: function(form, action) {
Ext.Msg.alert('错误', action.result.error);
}
});
} function queryArticleForUpdateEvent(){
var btn = Ext.get('show-btn');
articleWin = new Ext.ModelWin({title:'文章管理 - 编辑',width:800,height:700});
articleForm = new Ext.UpdateArticleForm({});
articleWin.addListener({'close':refreshArticleList});
articleWin.add(articleForm);
articleWin.show(btn);
var fckobj = new FCKeditor('article.mainContent', "100%", "450px");
fckobj.ToolbarSet = 'Default';
fckobj.ReplaceTextarea();
var record = articleGrid.getSelectionModel().getSelected();
var id = record.get('id');
articleForm.getForm().reader = new Ext.data.JsonReader({},
[
{name:'article.id',type:'int',mapping:'id'},
{name:'article.title',type:'string',mapping:'title'},
{name:'article.keyWords',type:'string',mapping:'keyWords'},
{name:'article.mainContent',type:'string',mapping:'mainContent'}
])
articleForm.load({url:'/RHSite/manager/Article)queryForId?id=' + id });
}
function refreshArticleList(){
articleGrid.getView().refresh();
//文章网格
Ext.ArticleGrid=Ext.extend(Ext.grid.GridPanel ,{
xtype:'grid',
id:'show-btn',
title:'所有文章',
width:'100%',
height:500,
columns:[
{
header:'编号',
sortable:true,
resizable:true,
dataIndex:'id',
width:'10%'
},
{
header:'标题',
sortable:true,
resizable:true,
dataIndex:'title',
width:'70%'
},
{
header:'作者',
sortable:true,
resizable:true,
dataIndex:'updateTime',
width:'10%'
}
,
{
header:'更新时间',
sortable:true,
resizable:true,
dataIndex:'updateTime',
width:'10%'
}
],
bbar: new Ext.PagingToolbar({
store: articleStore,
displayInfo: true,
pageSize: 5,
prependButtons: true
}),
listeners:{
"rowdblclick":queryArticleForUpdateEvent
}, initComponent: function(){
Ext.ArticleGrid.superclass.initComponent.call(this);
}
})
Ext.AddArticleForm=Ext.extend(Ext.form.FormPanel ,{
xtype:"form",
title:'',
labelWidth:100,
labelAlign:"left",
layout:"form",
width:'100%',
heigth:'100%',
bodyStyle:'padding:5px,5px,5px,5px;',
initComponent: function(){
this.items=[
{
name:'article.title',
xtype:"textfield",
fieldLabel:"标题",
anchor:"90%"
},
{
name:'article.keyWords',
xtype:"textfield",
fieldLabel:"关键字",
anchor:"70%"
},
{
hiddenName:'article.classify.id',
xtype:"combo",
triggerAction:"all",
fieldLabel:"分类",
loadingText:"正在加载数据...",
anchor:"50%",
store : articleClsStore,
valueField : "id",
displayField : "name",
selectOnFocus:true
},
{
hiddenName:'article.special.id',
xtype:"combo",
triggerAction:"all",
fieldLabel:"专题",
loadingText:"正在加载数据...",
anchor:"50%",
store : articleSpcStore,
valueField : "id",
displayField : "name",
selectOnFocus:true
},{
hiddenName:'article.addTime',
xtype:"datefield",
fieldLabel:"有效时间",
anchor:"50%",
format: 'Y-m-d H:i:s'
},{
name:'article.mainContent',
xtype:"textarea",
anchor:"90%",
fieldLabel:"内容",
height:600,
width:450
},{
xtype:"button",
text:"保 存",
listeners:{
'click':addArticleEvent
}
}
],
Ext.AddArticleForm.superclass.initComponent.call(this);
}
})
Ext.UpdateArticleForm=Ext.extend(Ext.form.FormPanel ,{
xtype:"form",
title:'',
labelWidth:100,
labelAlign:"left",
layout:"form",
width:'100%',
heigth:'100%',
bodyStyle:'padding:5px,5px,5px,5px;',
initComponent: function(){
this.items=[
{
name:'article.id',
xtype:"hidden",
anchor:"90%"
},
{
name:'article.title',
xtype:"textfield",
fieldLabel:"标题",
anchor:"90%"
},
{
name:'article.keyWords',
xtype:"textfield",
fieldLabel:"关键字",
anchor:"70%"
},
{
hiddenName:'article.classify.id',
xtype:"combo",
triggerAction:"all",
fieldLabel:"分类",
loadingText:"正在加载数据...",
anchor:"50%",
store : articleClsStore,
valueField : "id",
displayField : "name",
selectOnFocus:true
},
{
hiddenName:'article.special.id',
xtype:"combo",
triggerAction:"all",
fieldLabel:"专题",
loadingText:"正在加载数据...",
anchor:"50%",
store : articleSpcStore,
valueField : "id",
displayField : "name",
selectOnFocus:true
},{
hiddenName:'article.addTime',
xtype:"datefield",
fieldLabel:"有效时间",
anchor:"50%",
format: 'Y-m-d H:i:s'
},{
name:'article.mainContent',
xtype:"textarea",
anchor:"90%",
fieldLabel:"内容",
height:600,
width:450
},{
xtype:"button",
text:"我的按钮",
listeners:{
'click':addArticleEvent
}
}
],
Ext.UpdateArticleForm.superclass.initComponent.call(this);
}
})
/****数据源****/
var articleStore = new Ext.data.Store({
reader:new Ext.data.JsonReader({
totalRecords:'totalCount',//分页时需要的参数
root:'root',//json格式的根节点
fields:[ //在数据库中映射的字段名
{name:'id',type:'int'},
{name:'title',type:'String'},
{name:'updateTime', type: 'date', dateFormat: 'n/j h:ia'}
]
}),
//发送请求得到以上数据
proxy:new Ext.data.HttpProxy({
url:webRoot + '/manager/Article)list'
}) }); var articleClsStore = new Ext.data.Store({
reader:new Ext.data.JsonReader({
totalRecords:'totalCount',//分页时需要的参数
root:'root',//json格式的根节点
fields:[ //在数据库中映射的字段名
{name:'id',type:'int'},
{name:'name',type:'String'}
]
}),
//发送请求得到以上数据
proxy:new Ext.data.HttpProxy({
url:webRoot + '/manager/ArticleClassify)list'
}) }); var articleSpcStore = new Ext.data.Store({
reader:new Ext.data.JsonReader({
totalRecords:'totalCount',
root:'root',
fields:[
{name:'id',type:'int'},
{name:'name',type:'String'}
]
}),
proxy:new Ext.data.HttpProxy({
url:webRoot + '/manager/ArticleSpecail)list'
})
});/****初始化****/
var articleGrid = new Ext.ArticleGrid({});
var articleWin ;
var articleForm ;
articleStore.load();
articleGrid.store = articleStore;
articleGrid.doLayout();
/****事件****/ function addArticleEvent(){
articleForm.getForm().submit({
waitMsg: '正在提交数据...',
waitTitle: '提示',
method: 'post',
url:webRoot + '/manager/Article)add',
success: function(form, action) {
var flag=action.result.success;
Ext.Msg.alert('提示',flag);
if(flag == '提交成功'){
Ext.Msg.alert('提示',flag);
addArticleForm.getForm().reset();
}
},
failure: function(form, action) {
Ext.Msg.alert('错误', action.result.error);
}
});
} function queryArticleForUpdateEvent(){
var btn = Ext.get('show-btn');
articleWin = new Ext.ModelWin({title:'文章管理 - 编辑',width:800,height:700});
articleForm = new Ext.UpdateArticleForm({});
articleWin.addListener({'close':refreshArticleList});
articleWin.add(articleForm);
articleWin.show(btn);
var fckobj = new FCKeditor('article.mainContent', "100%", "450px");
fckobj.ToolbarSet = 'Default';
fckobj.ReplaceTextarea();
var record = articleGrid.getSelectionModel().getSelected();
var id = record.get('id');
articleForm.getForm().reader = new Ext.data.JsonReader({},
[
{name:'article.id',type:'int',mapping:'id'},
{name:'article.title',type:'string',mapping:'title'},
{name:'article.keyWords',type:'string',mapping:'keyWords'},
{name:'article.mainContent',type:'string',mapping:'mainContent'}
])
articleForm.load({url:'/RHSite/manager/Article)queryForId?id=' + id });
}
function refreshArticleList(){
articleGrid.getView().refresh();
解决方案 »
- JQuery ui .tabs(options) 方法的疑问
- jQuery 插件问题为什么许多插件在都会用到 return this.each(function(){})
- 高手请进 请问下面的焦点图 还能用什么方法写去下面的效果
- jquery 超级select插件 v3.2.0.0版本 支持汉字、头写拼音、英文快速定位查询的超级select插件。可方向键、tab 键快速选择.
- 很难的一个问题,至今没解决
- js定义全局数组变量,function为什么不能访问
- document.referrer 什么意思
- 求一个函数,给如网址,得到该网址的标题。。。
- 在vbscript中的asc()函数及chr()函数,在javascript中是什么?
- 网页中嵌入的REAL文件在REALONE中如何屏蔽鼠标右键 ,用javascript可以实现吗?
- ewebeditor无法上传word图片问题
- asp.net C# 怎样获取jquery动态生成控件的值
articleGrid.getView().refresh();//此处一刷新就报错.
}