当前位置:编程学习 > JAVA >>

动态加载表单数据的例子

<script type="text/javascript">
var sm = new Ext.grid.CheckboxSelectionModel({
dataIndex:"roleId"
});
  
var cm=new Ext.grid.ColumnModel([  
sm,
{
header : "员工编号",
dataIndex : "eid",
sortable:true
}, {
header : "员工姓名",
dataIndex : "ename"
}, {
header : "邮箱",
dataIndex : "eemail"
}, {
header : "地址",
dataIndex : "eaddress"
}, {
header : "工资",
dataIndex : "salary"
},{
header:"部门",
dataIndex:"did"
}
]) 
var store = new Ext.data.JsonStore({
url : 'getEmployeeWeb?id='+<%=id%>,
root : 'rows',
fields : ['did', 'eemail', 'eaddress', 'ename', 'eid', 'salary']
});
Ext.onReady(function() {
store.load({ params: { start: 0, limit: 2 }});
var grid = new Ext.grid.GridPanel({
id:'employeegrid',
renderTo : "employee",
title : "员工信息",
height : 635,
width : 900,
cm:cm,
store : store,
autoExpandColumn : 2,
sm:sm,
trackMouseOver:true,
stripeRows:true,
viewConfig: {   
                            forceFit:true ,//平均分配列
                             columnsText:"显示/隐藏列",  
                    sortAscText:"正序排列",  
                    sortDescText:"倒序排列"  
            },
            //分页
           bbar:new Ext.PagingToolbar({
           store:store,           //数据源
           pageSize:2,
           displayInfo:true,
           displayMsg:'当前记录 {0} -- {1} 条 共 {2} 条记录', //显示右下角信息
           emptyMsg:"No results to display",
           prevText:"上一页",
           nextText:"下一页",
           refreshText:"刷新",
           lastText:"最后页",
           firstText:"第一页",
           beforePageText:"当前页",
           afterPageText:"共{0}页"
                   }), 
                   tbar:  //工具条  
                [  
                {                      
                    text: '添加',  
                    handler: function(btn, pressed)  
                    {  
                          AddEmployeeInfo();       //添加新的员工信息  
                    }  
                }, '-',                 
                {                      
                    text: '修改',  
                    handler: function(btn, pressed)  
                    {    
                           var row=Ext.getCmp("employeegrid").getSelectionModel().getSelections();//选择行的个数  
                                 if(row.length==0)  
                                {  
                                    Ext.Msg.alert("提示信息","请您至少选择一个!");  
                                }  
                                else if(row.length>1){    
                                    Ext.Msg.alert("提示信息","对不起只能选择一个!");  
             &nbs

补充:web前端 , JavaScript ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,