52,795
社区成员




- var STUDENT=Ext.data.Record.create([
- {name:"sid",type:"string"},
- {name:"sname"},
- {name:"birthday",type:"string"},//type:"date",dataFormat:"Y-m-d"},
- {name:"city",type:"string"},
- {name:"stature",type:"int"}
- ]);
- Ext.apply(Ext.form.VTypes, {
- LengthLimit: function(v) {
- return v.length<=10
- },
- LengthLimitText: "字符串长度不能大于10",
- IntLimit:function(v){
- return v<300;
- },
- IntLimitText:"身高不能大于300"
- });
- /********************
- *表格,显示人员信息,继承自Ext.grid.GridPanel
- *
- ********************/
- StudentListGrid=Ext.extend(Ext.grid.GridPanel,{
- _store:null,
- _tbar:null,
- _addWin:null,
- _updateWin:null,
- constructor:function(){
- this._store=new Ext.data.JsonStore({
- autoLoad:true,
- url : "grid_service.jsp?action=getAllStudents",
- root:"rows",
- id:"id",
- fields:STUDENT,
- sortInfo:{field: "sid", direction: "DESC"}
-
- });
- this._tbar=new Ext.Toolbar({
- id:"mainMenu",
- items:["-",
- {
- text:"增加用户",
- id:"addBtn",
- iconCls:"adduser",
- handler:function(){
-
- this._addWin.show();
- this._addWin._form.getForm().reset();
- },
- scope:this
- },"-",
- {
- text:"修改用户",
- id:"updateBtn",
- iconCls:"modifyuser",
- handler:this.updateFn,
- scope:this
- },"-",
- {
- text:"删除用户",
- id:"delBtn",
- iconCls:"deleteuser",
- handler:this.deleteFn,
- scope:this
- },"-","->",
- {
- xtype:"textfield",
- fieldLabel:"请输入姓名",
- id:"searchName",
- width:100,
- emptyText:"-请输入姓名"
- },"-",{
- text:"搜索",
- width:50,
- iconCls:"search",
- handler:this.searchFn,
- scope:this
- },"-"
- ]
-
- });
- this._addWin=new AddNewStudentWindow();
- this._updateWin=new UpdateStudentWindow();
- StudentListGrid.superclass.constructor.call(this,{
- title:"学生列表",
- renderTo:Ext.getBody(),
- id:"main_grid",
- frame:true,
- height:300,
- width:500,
- tbar:this._tbar,
- store:this._store,
- sm: new Ext.grid.RowSelectionModel({
- singleSelect:true
- }),
- columns:[
- {header:"SID",dataIndex:"sid",hidden:true},
- {header:"姓名",dataIndex:"sname"},
- {header:"生日",dataIndex:"birthday",renderer:this.birthdayFn},
- {header:"所在城市",dataIndex:"city"},
- {header:"身高",dataIndex:"stature"}
- ]
-
- });
-
-
-
- },
- birthdayFn:function(value){
-
- if(typeof(value)=="string")
- return value.substring(0,10);
- else
- return Ext.util.Format.date(value,"Y-m-d");
- },
- updateFn:function(){
- var sm=this.getSelectionModel();
- if(sm.getCount() == 0) {
- Ext.Msg.show({
- title : '注意!',
- msg : '请选择需要修改的学生!',
- icon : Ext.MessageBox.WARNING,
- buttons : Ext.MessageBox.OK
- });
- return;
- }
- var _record=sm.getSelected();
- if(_record.data.birthday.length>=10)
- _record.data.birthday=_record.data.birthday.substring(0,10);
-
- this._updateWin._form.getForm().loadRecord(_record);
-
- this._updateWin.show();
- },
- deleteFn:function(){
-
- },
- searchFn:function(){
-
- }
- });
- /*******************************************
- *增加人员和修改人员时所用到的Form,继承自Ext.form.FormPanel
- *
- *
- ****************************************/
- StudentFormPanel=Ext.extend(Ext.form.FormPanel,{
- constructor:function(){
-
- StudentFormPanel.superclass.constructor.call(this,{
- width:340,
- frame:true,
- plain:true,
- layout:"form",
-
- labelWidth:60,
- labelAlign:'right',
- items:[
- { xtype:"hidden",
- fieldLabel:"id",
- id:"sid",
- value:"",
- width:200},
- {
- xtype:"textfield",
- fieldLabel:"姓 名",
- vtype:"LengthLimit",
- id:"sname",
- value:"",
- width:200
- },
- {
- xtype:"datefield",
- fieldLabel:"生 日",
- id:"birthday",
- width:200,
- format:"Y-m-d",
- editable:false,
- value:new Date()
- },
- {
- xtype:"textfield",
- fieldLabel:"所在城市",
- id:"city",
- width:200,
- value:""
- },
- {
- xtype:"textfield",
- fieldLabel:"身 高",
- id:"stature",
- width:200,
- vtype:"IntLimit",
- value:""
- }
- ]
-
-
- });
- }
- });
- /*************************************
- *增加用户是的弹出窗口,继承自Ext.Window
- *
- **************************************/
- AddNewStudentWindow=Ext.extend(Ext.Window,{
- _form:null,
- constructor:function(){
-
- this._form=new StudentFormPanel();//这里新建了FormPanel
- AddNewStudentWindow.superclass.constructor.call(this,{
-
- title:"增加用户",
- width:350,
- frame:true,
- plain:true,
- closeAction:"hide",
- autoDestroy:true,
-
- items:[this._form],
- modal:true,
- buttons:[
- {text:"保存",
- iconCls:"sure",
- handler:this.sureFn,
- scope:this},
- {text:"重置",
- iconCls:"reset",
- handler:this.resetFn,
- scope:this},
- {text:"关闭",
- iconCls:"close",
- handler:this.closeFn,
- scope:this}
- ]
- });
-
- },
- sureFn:function(){
-
- },
- resetFn:function(){
-
-
- },
- closeFn:function(){
- this.hide();
- }
- });
- /*****************************
- *更新用户时调用的窗口
- *
- ******************************/
- UpdateStudentWindow=Ext.extend(Ext.Window,{
- _form:null,
- constructor:function(){
-
- this._form=new StudentFormPanel();//新建FormPanel
- UpdateStudentWindow.superclass.constructor.call(this,{
-
- title:"修改用户",
- width:350,
- frame:true,
- plain:true,
- closeAction:"hide",
- autoDestroy:true,
-
- items:[this._form],
- modal:true,
- buttons:[
- {text:"保存",
- iconCls:"sure",
- handler:this.sureFn,
- scope:this},
- {text:"重置",
- iconCls:"reset",
- handler:this.resetFn,
- scope:this},
- {text:"关闭",
- iconCls:"close",
- handler:this.closeFn,
- scope:this}
- ]
- });
-
- },
- sureFn:function(){
- },
- resetFn:function(){
-
- },
- closeFn:function(){
- this.hide();
- }
- });
Test.superclass.constructor.call(this,{name: 'king'})
这样Test中就有了一个name的属性了,值是king;其实你没有必要一定要搞懂具体的含义。目前你只需要
它是这样用的,当成语法来用就可以了。等你的知识累计到一定程度自然就知道了。
你的问题描述得不够清晰