六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 67|回复: 0

ext 带条件查询的 分页

[复制链接]

升级  29.33%

24

主题

24

主题

24

主题

秀才

Rank: 2

积分
94
 楼主| 发表于 2013-1-29 11:31:26 | 显示全部楼层 |阅读模式
好像对于EXT 一直没有特别深入的研究...不知道缺在什么地方,这是我自己学习的语言,总觉得 代码的质量存在问题..
发上来 大家看一下.
 
ext 带搜索条件的 查询以及分页
 

function QueryString(){var name,value,i;var str=location.href;var num=str.indexOf("?")str=str.substr(num+1);var arrtmp=str.split("&");for(i=0;i < arrtmp.length;i++){num=arrtmp[i].indexOf("=");if(num>0){name=arrtmp[i].substring(0,num);value=arrtmp[i].substr(num+1);this[name]=value;}}}Ext.onReady(function(){    var fm = Ext.form;    var Request=new QueryString();var ID="";//Request["wlid"];//    var zlUrl=getRootPath()+'servlet/SearchGoods?change=searchallGoods';    var grid = null;    var page_size = 60;    var cm = new Ext.grid.ColumnModel({        defaults: {            sortable: true           },        columns: [ new Ext.grid.CheckboxSelectionModel(),               new Ext.grid.RowNumberer(),            {                header: '客户编号',                dataIndex: 'KHcode'            }, {                header: '材料编号',                dataIndex: 'goodsCode'             },{                header: '材料名称',                dataIndex: 'shortName'             }, {                header: '规格型号',                dataIndex: 'style'             }, {                header: '单位',                dataIndex: 'unitName'             }, {                header: '封装',                dataIndex: 'APPROVALNO'             }, {                header: '厂家',                dataIndex: 'FACTORY'             }, {                header: '库存数量',                dataIndex: 'STCount'             }, {                header: '成本单价',                dataIndex: 'aprice'             }, {             id: 'description',                header: '参考进价',                dataIndex: 'PPRICE'             }, {                header: '参考售价',                dataIndex: 'SPRICE'             }, {                header: '',                dataIndex: 'unitId',                hidden:true,                hideable:false             }, {                header: '',                dataIndex: 'goodsId',                hidden:true,                hideable:false             }        ]    });     var store = new Ext.data.Store({        proxy: new Ext.data.HttpProxy({            url: zlUrl        }),        reader: new Ext.data.JsonReader({        totalProperty: 'totalCount',            root: 'gridRows',            fields: [            {name:'KHcode'},                {name: 'goodsCode', mapping: 'goodsCode'},                {name: 'shortName'},                 {name: 'style'},                {name:'unitName'},                {name: 'APPROVALNO'},                {name: 'FACTORY'},                {name:'STCount'},                {name: 'aprice'},                {name: 'PPRICE'},                {name: 'SPRICE'},                {name: 'unitId'},                {name: 'goodsId'}            ]        })    });    //导航栏    var dsSupplier = new Ext.data.Store({        proxy: new Ext.data.HttpProxy({           url:getRootPath()+'servlet/SearchGoods?change=sgoodsType'        }),        reader: new Ext.data.JsonReader({        root: 'gridRows',        totalProperty: 'totalCount'        }, [        {name: 'typeName', mapping: 'typeName'},           {name: 'typeId', mapping: 'typeId'}                   ])    });    var typeid="";     var combo = new Ext.form.ComboBox({        typeAhead: true,        triggerAction: 'all',        selectOnFocus :true,        listClass: 'x-combo-list-small',        store:dsSupplier,        valueField:'typeId',        displayField:'typeName',        //editable: true,        listeners:{    select: function(){    Ext.get('typeId').dom.value=this.getValue();       store.load({              params:{              start : 0,        limit : page_size,                       typeId:this.getValue()//取得搜索表单文本域的值,发送到服务端                    }              });    }}    });            grid = new Ext.grid.EditorGridPanel({    autoScroll:true,        store: store,        sm : new Ext.grid.CheckboxSelectionModel(),cm: cm,        renderTo: 'editor-grid',        width: Ext.get("content").getWidth(),        height: Ext.get("content").getHeight(),        autoExpandColumn: 'description', // column with this id will be expanded        title: '客户物料详细信息',        frame: true,        clicksToEdit: 1,                viewConfig:{        forceFit:true,//所有列都改变宽度autoFill:true,sortAscText:'升序',sortDescText:'降序',columnsText:'显示列'},        tbar: [{              text: '请选择类别:'           },combo,'-',           {xtype:'textfield',fieldLabel: '搜索框',            id: 'searchContent',            name: 'searchContent'           },'-',           {           text:'搜索',           handler:function(){           //Ext.get('searchContent').dom.value=Ext.getCmp('searchContent').getValue();       store.load({              params:{              start : 0,        limit : page_size,     storeId:Request["STOREID"],   wlid:Request["WLID"],     typeId:Ext.get('typeId').dom.value,                       searchContent:Ext.getCmp('searchContent').getValue()                    }              });           }           },           '-',{           text: '确定',           handler:function(){           var json = [];           var recordDtlArray = grid.getSelectionModel().getSelections();for(i = 0; i<recordDtlArray.length;i++){    json.push(recordDtlArray[i].data);}if(json.length==0){Ext.Msg.alert('信息','没有选中数据');return;}//发送保存请求Ext.lib.Ajax.request('POST',getRootPath()+'servlet/SearchGoods?change=checkedGoods',{success:function(request){var message = request.responseText;window.returnValue=message;window.close();},failure:function(){Ext.Msg.alert("错误", "与后台联系的时候出现了问题");}},'&members='+encodeURIComponent(Ext.encode(json)));           }           }],bbar:new Ext.PagingToolbar({    pageSize : page_size,    store : store,    displayInfo : true,    displayMsg: '',            emptyMsg: "没有数据..",            beforePageText:'第',            afterPageText:'页,共{0}页'   })           });    Ext.getCmp('searchContent').setValue(decodeURI(Request["codestr"]));    store.load({     params : {     typeId:Ext.get('typeId').dom.value,     searchContent:Ext.getCmp('searchContent').getValue(),     storeId:Request["STOREID"],   wlid:Request["WLID"],     start : 0,        limit : page_size    }    });    store.on('beforeload',function(){  Ext.apply(this.baseParams,{   typeId:Ext.get('typeId').dom.value,   storeId:Request["STOREID"],   wlid:Request["WLID"],   searchContent:Ext.getCmp('searchContent').getValue()  });});        window.onresize = function(){     grid.setWidth(0);         grid.setHeight(0);         grid.setWidth(Ext.get("content").getWidth());         grid.setHeight(Ext.get("content").getHeight()); };});
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表