一个常用的代码范例

/**
 * 订单录入
 */
mortgage.userManager = function() {
 Ext.onReady(function() {
  Ext.QuickTips.init();
  // 记录json对应设置(如果json数据只有值没有名称,需要)
  //var data = [['1','sales', '43729050','cherry','SH','159*','26465','SH,BJ']]; 
  var data = [];
  
  /*******************************************************************
   * 列表标题以及数据显示设置
   ******************************************************************/
  var colModel = new Ext.grid.ColumnModel( [
                                           
    new Ext.grid.RowNumberer(), {
     header : 'id',
     dataIndex : 'id',
     hidden : true
    }, {
     header : '角色',
     sortable : false,
     dataIndex : 'role'
    }, {
     header : "员工号",
     sortable : false,
     dataIndex : 'staffId'
    }, {
     header : "姓名",
     sortable : false,
     dataIndex : 'name'
    },
    {
     header : "部门",
     sortable : false,
     dataIndex : 'dept'
    },   
    {
     header : "行所",
     sortable : false,
     dataIndex : 'branch'
    }, {
     header : "手机号",
     sortable : false,
     dataIndex : 'mobile'
    }, {
     header : "分机号",
     sortable : false,
     dataIndex : 'ext'
    }, {
     header : "下辖行所",
     sortable : false,
     dataIndex : 'befBranch'
    }]);
  
 var record=Ext.data.Record.create([
   {
   name : 'id'
   }, {
    name : 'role'
   }, {
    name : 'staffId'
   }, {
    name : 'name'
   } ,{
    name : 'dept'
   },   
   {
      name : 'branch'
   }, {
    name : 'mobile'
   }, {
    name : 'ext'
   }, {
    name : 'befBranch'
   }
 ]);
 
 var reader= new Ext.data.JsonReader({
  root : "userList",
  fields : record
 });

  /*******************************************************************
   * 获取数据
   ******************************************************************/
  var dataStore = new Ext.data.Store( {
   proxy : new Ext.data.HttpProxy({
    url : getContextPath()+'/userManager.htm'
  }),
     reader : reader
  
  });
  
  /*******************************************************************
   * 获取roleList数据
   ******************************************************************/
  var roleList = new Ext.data.JsonStore({       
   url:getContextPath()+'/selectRole.htm',
      root:'userList',
      fields:['roleId','roleName'],
      autoLoad:true        
  })
  
  /*******************************************************************
   * 设置检索参数
   ******************************************************************/
  dataStore.on('beforeload', function(dataStore) {
//   var para = {
//    cardNo : ''
//   };
//   Ext.apply(dataStore.baseParams, para);
  });
  /*******************************************************************
   * 加载第一页信息
   ******************************************************************/
  dataStore.load( {
   params : {
    start : 0,
    limit : 10
   }
  });

  /*******************************************************************
   * 翻页条定义
   ******************************************************************/
  var nextPageButton = new Ext.Button(
    {
     text : '下一页',
     disabled : true,
     handler : function() {

     }
    });
  var myMenuBar = [ '->', '-', nextPageButton ];
  
 
  /**
   * 按钮定义
   */
  var getApplyNoButton = new Ext.Button({
   
   text : '查询',
   width : 100,
   handler : function(){
    infoForm.getForm().submit({
      timeout:60000,
         waitMsg:'正在查询,请稍后...',
         failure:function(form,action){        
         Ext.Msg.alert("failure","查询失败!");
         },
         success:function(form,action){
             var dataManage = action.result.userList;
                            dataStore.loadData(action.result);
 
         }       
   });
   }
 
  });
  var findAttachmentButton = new Ext.Button({
   text : '查询全部',
   width : 100,
   handler : function(){
    infoForm.getForm().reset();
    infoForm.getForm().submit({
      timeout:60000,
         waitMsg:'正在查询,请稍后...',
         failure:function(form,action){        
         Ext.Msg.alert("failure","查询失败!");
         },
         success:function(form,action){
           var dataManage = action.result.userList;
                          dataStore.loadData(action.result);

         }       
   });
   }   
  });
  
  
  
  
  
  var upbutton = new Ext.Button({
   text : '导出用户列表',
   id : 'button1',
   name : 'button1',
   handler : function() {
//    infoForm.getForm().submit({
//     url : getContextPath()+'/downloadUserList.htm',
//      timeout:60000,
//         waitMsg:'正在查询,请稍后...',
//         failure:function(form,action){        
////         Ext.Msg.alert("failure","查询失败!");
//         },
//         success:function(form,action){
//             var dataManage = action.result.userList;
////                           dataStore.loadData(action.result);
// 
//         }
//         });
    
    
    var staffids = $("#staffids").val();
    var branchNo=$("input[name='branchNo']").val();    
    var staffNo=$("#staffNo").val();
    var branchs=$("input[name='branchs']").val();
    var roles = $("input[name='roles']").val(); 
 
     window.location.href = getContextPath()+'/downloadUserList.htm?staffids='+staffids+"&branchNo="+branchNo+"&staffNo="+staffNo+"&branchs="+branchs+"&roles="+roles;
   
   }
  });
  

  
  /*******************************************************************
   * 列表定义
   ******************************************************************/
  var grid = new Ext.grid.GridPanel( {
   width:'auto',
      height : document.body.clientHeight-200,
   id : 'button-grid',
   store : dataStore,
   cm : colModel,
   stripeRows : true,
   viewConfig : {
    forceFit : true
   },
   //工具条
   tbar : [{
    text: '添加',
    iconCls:'add',
    tooltip:'新增一个用户',
    handler : function(){
     mortgage.userManager.addUserBasic(dataStore);
    }
   },
   {
    text: '编辑',
    iconCls : 'edit',
    handler : function(){
    var selectRecord = grid.getSelectionModel()
     .getSelected();
   if (null == selectRecord) {
    Ext.MessageBox.alert("提示", "至少选择一条数据!");
   } else {
    mortgage.userManager.edit(dataStore,selectRecord,roleList);
   }
  
    }
   },
   {
    text: '删除',
    iconCls:'remove',
    tooltip:'删除一条记录',
    handler : function(){     
     mortgage.userManager.deleteUser(dataStore,grid);     
     
    }
   }
   ],
   // 菜单条
   loadMask : {
    msg : '数据加载中,请稍侯……'
   },
   // 分页条
   bbar : myMenuBar,
   frame : true,
   title : '',
   iconCls : 'icon-grid'
  });
/**
 * 角色下拉列表查询
 */
  var roleStore = new Ext.data.JsonStore({
   url:getContextPath()+'/selectRole.htm',
      root:'userList',
      fields:['roleId','roleName']  
  
  });
  roleStore.load();
  
  
/**
 * 行所下拉列表查询
 */ 
  
  var branchStore = new Ext.data.JsonStore({
   url:getContextPath()+'/selectBranch.htm',
      root:'userList',
      fields:['branchId','branchId']  
  
  });
  branchStore.load(); 
 
 
  /**
   * 订单内容信息
   */
  var infoForm = new Ext.FormPanel({
   url : getContextPath()+'/userManager.htm',
   labelAlign : 'right',
   layout : 'form',
   labelSeparator : ':',
   width : document.body.clientWidth > PANELMINWIDTH?document.body.clientWidth-20:PANELMINWIDTH-20,
   height : document.body.clientHeight,
   items : [{
    title : '基础信息',
    xtype : 'fieldset',
    layout : 'column',
    buttonAlign : 'center',
    collapsible : true,
    height : 130,
    buttons : [getApplyNoButton,findAttachmentButton,upbutton],
    items : [{
     columnWidth : .33,
     layout : 'form',
     items : [{
        xtype : 'textfield',
        fieldLabel : '员工号',
        name : 'staffids',
        id : 'staffids',
        width : 140,
        value : '',
        readOnly : false
       },{
        
         xtype : 'combo',
         fieldLabel : '行所',
         store : branchStore,
         forceSelection : true,
         width : 140,
         //emptyText : '请选择',
         valueField : "branchId",
         displayField : "branchId",
         mode : 'remote',
         name : 'branchNo',
         value : '',
         hiddenName : 'branchNo',
         triggerAction : 'all'
       }]
        
    },{
     columnWidth : .33,
     layout : 'form',
     items : [{
        xtype : 'textfield',
        fieldLabel : '姓名',
        name : 'staffNo',
        id : 'staffNo',
        width : 140,
        hidden : false
       }, {
        xtype : 'combo',
        fieldLabel : '部门',
        store : new Ext.data.JsonStore({
         fields : [ 'name', 'value' ],
         baseParams:{typeId:'h'},
         root:'CodeBase',
         url:getContextPath()+'/CodeBase.htm',
         autoLoad:true
        }),
        forceSelection : true,
        width : 140,
        //emptyText : '请选择',
        valueField : 'value',
        displayField : 'name',
        mode : 'remote',
        name : 'branchs',
        value : '',
        hiddenName : 'branchs',
        triggerAction : 'all'
       }]
    },{
     columnWidth : .33,
     layout : 'form',
     items : [{
      xtype : 'combo',
      fieldLabel : '角色',
      store : roleStore,
      forceSelection : true,
      width : 140,
      //emptyText : '请选择',
      valueField : "roleId",
      displayField : "roleName",
      mode : 'remote',
      name : 'roles',
      value : '',
      hiddenName : 'roles',
      triggerAction : 'all'
     }]
    }]
   },{
    title : '查询结果',
    xtype : 'fieldset',
    layout : 'column',
    bodyStyle : 'padding:5px,0px,2px,0px',
    collapsible : true,
    items : [ grid ]
   }]
  });
  /***********************************************************************
   * 容器panel定义
   **********************************************************************/
  var containerPanel = new Ext.Panel({
     layout : 'column',
     frame : true,
     applyTo : 'manage_grid_div',
     id : 'containerPanel',
     width : document.body.clientWidth > PANELMINWIDTH
       ? document.body.clientWidth
       : PANELMINWIDTH,
     height : document.body.clientHeight,
     items : [infoForm]
    });
  /***********************************************************************
   * 页面宽度高度自适应处理
   **********************************************************************/
  Ext.EventManager.onWindowResize(function(w, h) {
     try {
      if (document.body.clientWidth > PANELMINWIDTH) {
       containerPanel.setWidth(document.body.clientWidth);
      } else {
       containerPanel.setWidth(PANELMINWIDTH);
      }

     } catch (e) {
     }

    });

 });
};
mortgage.userManager();

 

JavaScript电子书,包括了JavaScript的大部分知识,可以帮助读者快速入门。内容如下: 第1章 JavaScript语言概述 1.1 JavaScript是什么 1.1.1 JavaScript简史 1.1.2 JavaScript有何特点 1.2 JavaScript能做什么 1.2.1 表单数据合法性验证 1.2.2 页面特效 1.2.3 交互式菜单 1.2.4 动态页面 1.2.5 数值计算 1.3 JavaScript编程起步 1.3.1 “Hello World!”程序 1.3.2 选择JavaScript脚本编辑器 1.4 如何引入JavaScript脚本代码 1.4.1 通过与标记对引入 1.4.2 通过标记的src属性引入 1.4.3 通过JavaScript伪URL引入 1.4.4 通过HTML文档事件处理程序引入 1.5 嵌入JavaScript脚本代码的位置 1.5.1 在与标记对之间放置 1.5.2 在与标记对之间放置 1.5.3 在两个标记对之间混合放置 1.6 选择合适的浏览器 1.7 处理不支持JavaScript脚本的情况 1.7.1 使用标记对直接屏蔽法 1.7.2 使用和标记对给出提示信息 1.8 JavaScript的实现基础 1.8.1 ECMAScript 1.8.2 DOM 1.8.3 BOM 1.9 客户端与服务器端脚本 1.10 JavaScript与JScript、 VBScript 1.11 JavaScript与Java、Java applet 1.12 JavaScript的未来如何 1.13 本章小结 第2章 JavaScript语言入门 2.1 编程准备 2.1.1 编程术语 2.1.2 脚本执行顺序 2.1.3 大小写敏感 2.1.4 空白字符 2.1.5 分号 2.1.6 块 2.2 数值类型 2.2.1 整型和浮点数值 2.2.2 八进制和十六进制 2.3 变量 2.3.1 变量标识符 2.3.2 变量申明 2.3.3 变量作用域 2.4 弱类型 2.5 基本数据类型 2.5.1 Number型 2.5.2 String型 2.5.3 Boolean型 2.5.4 Undefined型 2.5.5 Null型 2.5.6 Function型 2.6 组合类型 2.6.1 Array型 2.6.2 Object型 2.7 运算符 2.7.1 赋值运算符 2.7.2 基本数学运算符 2.7.3 位运算符 2.7.4 位移运算符 2.7.5 自加和自减 2.7.6 比较运算符 2.7.7 逻辑运算符 2.7.8 逗号运算符 2.7.9 空运算符 2.7.10 ?...:运算符 2.7.11 对象运算符 2.7.12 typeof运算符 2.7.13 运算符优先级 2.8 核心语句 2.8.1 基本处理流程 2.8.2 if条件假设语句 2.8.3 switch流程控制语句 2.8.4 for循环语句 2.8.5 while和do-while循环语句 2.8.6 使用break和continue进行循坏控制 2.8.7 with对象操作语句 2.8.8 使用for…in进行对象循坏 2.8.9 含标签的语句 2.9 函数 2.9.1 函数的基本组成 2.9.2 全局函数与局部函数 2.9.3 作为对象的函数 2.9.4 函数递归调用 2.9.5 语言注释语句 2.9.6 函数应用注意事项 2.10 本章小结 第3章 JavaScript事件处理 3.1 什么是事件 3.2 HTML文档事件 3.2.1 事件捆绑 3.2.2 浏览器事件 3.2.3 HTML元素事件 3.2.4 IE扩展的事件 3.3 JavaScript如何处理事件 3.3.1 匿名函数 3.3.2 显式声明 3.3.3 手工触发 3.4 事件处理器的返回值 3.5 事件处理器设置的灵活性 3.6 现代事件模型与Event对象 3.7 IE4中的Event对象 3.7.1 对象属性 3.7.2 事件上溯 3.7.3 阻止事件上溯 3.7.4 事件改向 3.8 NN4中的Event对象 3.8.1 对象属性 3.8.2 事件捕获 3.8.3 关闭事件捕获 3.8.4 事件传递 3.9 DOM的解决之道
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值