zoukankan      html  css  js  c++  java
  • Extjs4.2.0 Store 的使用

    一:统计功能

    1.获得总行数起始值为1:
    store.getCount();

    2.某列数字求和:
    store.sum('Fhtje');//参数字段名

     二:载入数据

    load( [Object/Function options] )//参数一个Object 键值对,或一个方法的返回对象,如果用方法返回其实质还是一个Object

    //给出url地址,加载服务器返回的数据

    store.load({url : 'S/xs_markets/xs_markets_fy.data.asp?act=getData&markets_zy_Fid='+ formPanel.getForm().getValues().Fid

    //不给出url,会从store配置中自动获取

        ds_fy.load({
         params: {markets_zy_Fid:formPanel.getForm().getValues().Fid}; //load是一个read操作,参数默认附加到url,是GET提交
        });

    三:提交数据

    store.sync()

    默认是提交以下格式的数据,直接是个json对象向服务器提交,Request方法无法接收获取数据;,extjs之所以默认为这种方式提交,估计是服务器端有对应的方法直接使用该参数,俺业余写程序的吃亏啊。

    网上翻了3个小时,要asp支持接收这种数据,只有像无组件上传一样用ADODB.Stream读了在提取,还有其他一些php,.net.jsp等的处理办法,乱七八糟的方法;

    正确的解决办法是,配置proxy的write属性;这么简单的事情,为什么大神们要搞那么复杂,真坑!

     1 var ds_fy = Ext.create('Ext.data.Store', {
     2             model : 'dataModel_markets_fy',
     3             idProperty : 'Fid',
     4             proxy : {
     5                 type : 'ajax',
     6                 api : {
     7                     create : 'S/xs_markets/xs_markets_fy.data.asp?act=newData',
     8                     read : 'S/xs_markets/xs_markets_fy.data.asp?act=getData',
     9                     update : 'S/xs_markets/xs_markets_fy.data.asp?act=setData',
    10                     destroy : 'S/xs_markets/xs_markets_fy.data.asp?act=delData'
    11                 },
    12                 reader : {
    13                     type : 'json',
    14                     root : 'Body'
    15                 },
    16                 writer : {
    17                     encode : true,
    18                     type : 'json',
    19                     root : 'data'//服务器端直接用 Request.Form('data')接收
    20                 }
    21             }
    22         });

    当调用sync()执行create任务,Response数据返回格式应按照 proxy.reader设置,至少返回该新建Reocrd主键值;如{Body:{Fid:10}}

    当主键值被返回后,extjs 会自动填充sotre中该新建Record的id值;再次编辑该行,sync会执行 update任务;

    当调用sync()执行delete任务,如果服务器删除失败,extjs好像没有create任务那么智能,不能恢复UI界面中被Remove的record;需要手工恢复。

    如果您的实验中能自动恢复,麻烦您留个言;

    ExtJs之Ext.data.Store(1)

    in viewModel 延时加载

        stores: {
            xsT_cashFlow: {
                type: 'GridStore',
                entityName: 'xsT_cashFlow',
                listeners: {
                    'aftersync': {fn: this.afterSync, scope: this}
                }
            }
        },

     //grid.getStore().getProxy().getWriter().setWriteAllFields(true);

  • 相关阅读:
    兼容性问题
    Webfont 的兼容性问题[持续更新]
    WebView的坑[持续更新]
    [转]60fps on the mobile web
    IT男送什么礼物给女朋友呢?
    Lumia 1520 IE mobile window.devicePixelRatio
    Fiddler 故障
    IE(8~11+) 可用右键加速器
    [转]Zen Cart官网屏蔽中国用户访问的真正原因
    Internet Explorer Developer Channel 自动化测试 IE 浏览器
  • 原文地址:https://www.cnblogs.com/xsSystem/p/3095874.html
Copyright © 2011-2022 走看看