Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

添加学生详细信息查看

  • Loading branch information...
commit 4801e6eea89bb136da336473b879d96196246bc4 1 parent 9a432cd
@mouse-lin authored
View
12 app/controllers/students_controller.rb
@@ -1,12 +1,12 @@
class StudentsController < ApplicationController
#获取学生信息
def get_all_students
- students = []
- Student.all.each do |s|
- students.push(s.attributes.merge!({
- :class_name => s.classes.try(:name)
- }))
- end
+ students = Student.all.collect &fields_provider
+ #Student.all.each do |s|
+ # students.push(s.attributes.merge!({
+ # :class_name => s.classes.try(:name)
+ # }))
+ #end
render_json students
end
end
View
73 public/javascripts/PF/pages/settings_index.js
@@ -1,18 +1,81 @@
Pf.settings.homeIndex = {
panel: function(){
var grid = new Pf.classes.student();
+ var studentDetailFormPanel = this.createStuentDetail();
grid.store.load();
- var grid2 = new Pf.classes.student();
var panel = new Ext.TabPanel({
autoScroll : true,
activeTab: 0,
- autpLoad: true,
frame: true,
items: [
- { title: "学生主档", items: grid },
- { title: "学生主档", items: grid2 },
+ { title: "学生主档",
+ layout: "border",
+ items: [{region: "center",width: 900, items: grid },{ region:"east",width: 500, layout: "anchor", items:studentDetailFormPanel }]
+ },
+ { title: "学生主档", html: "mouse" },
]
});
return panel;
- }
+ },
+
+ createStuentDetail: function(){
+ var formPanel = new Ext.form.FormPanel({
+ title: "test",
+ anchor: "100% 100%",
+ autoScroll : true,
+ frame: true,
+ labelAlign : 'right',
+ items: [{
+ layout: 'column',
+ items:[
+ {
+ width : 150,
+ layout: 'fit',
+ items: [new Ext.form.FieldSet({
+ title : '头像',
+ layout : 'fit',
+ height : 130,
+ items :[{
+ html : '<span id="image"><img src="/images/Temp.png" height=110px width=120px alt="图片" /></span>'
+ }]
+ })]
+ },
+ {
+ defaults : { anchor : '95%'},
+ columnWidth: 1,
+ defaultType : 'textfield',
+ layout: "form",
+ items: [
+ {
+ fieldLabel: "学号",
+ name: "number"
+ },
+ {
+ fieldLabel: "姓名",
+ name: "name"
+ },
+ {
+ fieldLabel: "班级",
+ name: "classes"
+ },
+ {
+ fieldLabel: "性别",
+ name: "sex"
+ },
+ {
+ fieldLabel: "联系电话",
+ name: "phone"
+ },
+ {
+ xtype : 'textarea',
+ fieldLabel: "住址",
+ name: "home"
+ },
+ ]
+ }
+ ]
+ }]
+ });
+ return formPanel;
+ }
}
View
34 public/javascripts/PF/pages/student.js
@@ -3,44 +3,56 @@ Ext.ns("Pf.classes.student");
Pf.classes.student = Ext.extend(Ext.grid.EditorGridPanel,{
viewConfig: { forceFit: true },
height: 600,
+ sm: new Ext.grid.RowSelectionModel({
+ singleSelect: true
+ }),
initComponent : function () {
this.store = this.initStore();
this.cm = this.initCm();
this.tbar = this.initStudentTbar();
Pf.classes.student.superclass.initComponent.call(this);
},
+ initStudentEditor: function(){
+ var editor = new Ext.ux.grid.RowEditor({
+ saveText: 'Update'
+ });
+ return editor;
+ },
initStore: function(){
- var store = new Ext.data.JsonStore({
+ var store = new Pf.util.FieldsJsonStore({
fields: [
"name",
"number",
"sex",
"phone",
"home",
- "class_name",
+ "classes/name",
],
root: 'root',
url: '/students/get_all_students.json',
- totalProperty:'total',
- method:'GET',
});
return store;
},
initCm: function(){
var cm = new Ext.grid.ColumnModel([
new Ext.grid.RowNumberer(),
- { header: '学号', sortable: true, dataIndex: 'number',editor:new Ext.form.TextField()},
- { header: '姓名', sortable: true, dataIndex: 'name',editor:new Ext.form.TextField()},
- { header: '班级', sortable: true, dataIndex: 'class_name',editor:new Ext.form.TextField()},
- { header: '性别', sortable: true, dataIndex: 'sex',editor:new Ext.form.TextField()},
- { header: '联系电话', sortable: true, dataIndex: 'phone',editor:new Ext.form.TextField()},
- { header: '住址', sortable: true, dataIndex: 'home',editor:new Ext.form.TextField()},
+ { header: '学号', sortable: true, dataIndex: 'number'},
+ { header: '姓名', sortable: true, dataIndex: 'name'},
+ { header: '班级', sortable: true, dataIndex: 'classes/name'},
+ { header: '性别', sortable: true, dataIndex: 'sex'},
+ { header: '联系电话', sortable: true, dataIndex: 'phone'},
+ { header: '住址', sortable: true, dataIndex: 'home'},
]);
return cm;
},
initStudentTbar: function(){
+ var _this = this;
var tbar = [
- { iconCls: "add", text: "添加" },
+ {
+ iconCls: "add",
+ text: "添加",
+ handler: function(){ alert("niha")}
+ },
{ iconCls: "delete", text: "删除" },
{ iconCls: "table_edit", text: "编辑" },
{ iconCls: "table_edit", text: "详细" },
Please sign in to comment.
Something went wrong with that request. Please try again.