ExtjsMVC开发过程中遇到的具体问题总结

1.登陆相关问题

       1.如何在文本框中增加提示信息
             2.如何在文本框中触发回车事件
             3.如何在回车事件中触发按钮的动作
             总结:http://www.cnblogs.com/sdjnzqr/p/3922726.html

2.只读文本框样式设置

参考文章:http://stackoverflow.com/questions/9214297/how-do-i-change-color-of-a-textfield-using-extjs

 

3.关于查询数据返回的问题

  在真正的业务系统中,大部分数据返回时无法返回数据库中对应的实体,一般来说都是几个实体之间的混合属性,这就造成了如果使用MVC架构时,需要在做查询时,创建大量的Model,造成代码的复杂度,因此建议尽量少用Model,有可能的话尽量使用json。

4.Ajax调用的方式

http://blog.csdn.net/hrl_100/article/details/5639922
 
 
 
http://phpcode8.com/web/extjs/extjs-global-variable.html
 
 
 

would process the following server response for a successful submission:

{
       "success":true, // note this is Boolean, not string
      "msg":"Consignment updated"
    }

and the following server response for a failed submission:

{
    "success":false, // note this is Boolean, not string
    "msg":"You do not have permission to perform this operation"
    }
 
 
 
@RequestMapping(value="/sys/functiontree",produces="text/plain;charset=UTF-8")
@ResponseBody
    public String getTreeData()

第二种解决方案:通过修改XMl配置文件或者而修改源码来实现。

 

参考文章:

http://www.oschina.net/question/105887_114629?sort=time

http://blog.csdn.net/kissliux/article/details/14053761

 

注意:

我使用的是3.1.2的Spring包,在3.1.2版本中通过配置XML无法解决,只能通过修改源码或者继承类的方式实现。

另外:每个版本的StringHttpMessageConverter的实现方式不一样,注意实现方式。

 
 
     http://www.cnblogs.com/mrye/archive/2013/05/26/3100431.html
     http://ishowshao.com/blog/2012/08/17/extjs-4-trees/
 
 
 
 
 
 
 
refs属性的理解
 
参考文章:
    http://www.cnblogs.com/liuqxFuture/archive/2012/11/10/2763764.html
    http://czpae86.iteye.com/blog/1181110
 
 
 
 
 
 
 
 
    var bhcmsController = application.getController('BHCMSController');
        bhcmsController.init(self);
会造成在init方法执行两次会有问题,正确的应该是:
if(!Ext.ClassManager.isCreated('MyExt.controller.qxgl.UserController')){//判断controller是否已经加载;
                          Ext.require("MyExt.controller.qxgl.UserController", function () {
                                var userController = app.getController('qxgl.UserController');
                                app.getController('FirstPageController').addTab(record.get('id'),record.get('text'),'qxgl_userlist','true');
                            }, self);
                    }else{
                        app.getController('FirstPageController').addTab(record.get('id'),record.get('text'),'qxgl_userlist','true');
                    }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
http://blog.csdn.net/lc448986375/article/details/8019649
 
13.grid日期列显示的问题
 
通过renderer属性来将后台传过来的数字时间变成Extjs能够接受的时间
            text : '登陆时间',
                dataIndex : 'lastLogin',
                renderer: function(value){
                    return Ext.util.Format.date(new Date(1404098883000),'Y-m-d');
                }
 

14.DataGird分页的实现

参考文章:http://www.vipaq.com/Article/View/blog/239.html

后台实现时必须的三个参数:page,start,limit

代码实现:

var store = Ext.create('Ext.data.Store', {
            id:'simpsonsStore',
            autoLoad: false,
            fields:[
                    { name: 'id', type: 'string' },
                    { name: 'userCode',   type: 'string' },
                    { name: 'loginState', type: 'string' },
                    { name: 'lastLogin', type: 'string' },
                    ],
            pageSize: 10, // items per page
            proxy: {
                type: 'ajax',
                url: 'test/queryAllUsers.json',  // url that will load data with respect to start and limit params
                reader: {
                    type: 'json',
                    root: 'rows',
                    totalProperty: 'total'
                }
            }
        });
Ext.create('Ext.grid.Panel', {
            title : '查询结果',
            region : 'center',
            margin : '5 0 0 0',
            store: store, 
            columns : [ {
                text : '用户ID',
                dataIndex : 'id'
            }, {
                text : '用户编码',
                dataIndex : 'userCode',
                flex : 1
            }, {
                text : '登陆状态',
                dataIndex : 'loginState'
            }, {
                text : '登陆时间',
                dataIndex : 'lastLogin',
                renderer: function(value){
                    return Ext.util.Format.date(new Date(1404098883000),'Y-m-d');
                }
            } ],
             dockedItems: [{
                    xtype: 'pagingtoolbar',
                    store: store,   // same store GridPanel is using
                    dock: 'bottom',
                    displayInfo: true
                }],
        })
//带参数查询
store.on("beforeload",function(){
                Ext.apply(store.proxy.extraParams, {userid:button.up('form').down('textfield[name=id]').getValue(),
                    usercode:button.up('form').down('textfield[name=usercode]').getValue()});
            });
//datagrid查询            
            store.load({
                params:{
                    start:0,
                    limit: 10,
                }
            });

转载于:https://www.cnblogs.com/sdjnzqr/p/3937825.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值