关闭

扩展Ext的JsonReader

271人阅读 评论(0) 收藏 举报
分类:
var MyJsonReader = Ext.extend(Ext.data.JsonReader, {
	read: function(response){
        var json = response.responseText;
        var o = Ext.decode(json);
        if(!o)
        {
            throw {message: 'JsonReader.read: Json object not found'};
        }
        
        this.responseJsonObject = o;
        return this.readRecords(o);
    }
});

var myReader = new MyJsonReader(
	{totalProperty: "totalCount", root: "root"},
	[
	 	{name: "priceId"},
	 	{name: "areaCode"},
	 	{name: "deptCode"},
	 	{name: "deptName"},
	 	{name: "priceTypeCode"},
	 	{name: "priceBallotQty"},
	 	{name: "priceWeightQty"},
	 	{name: "createdEmpCode"},
	 	{name: "createdTm"},
	 	{name: "modifiedEmpCode"},
	 	{name: "modifiedTm"}
	]
);

var store = new Ext.data.Store({
		proxy: new Ext.data.HttpProxy({url:"queryPriceByPage.action"}),
		reader: myReader,
		listeners: {
			beforeLoad: function(){
				if(Ext.isEmpty(Ext.getCmp("areaCodeCombox").getValue(), false))
				{
					Ext.Msg.alert("提示", "请选择地区代码!");
					return false;
				}
				
				this.baseParams = queryFormPanel.getForm().getValues();
	  			this.baseParams['limit'] = gridPanel.getTopToolbar().pageSize;
			},
			load: function(){
				Ext.getCmp("deptCountLabel").setText("  网点总数:" 
						+ myReader.responseJsonObject.allDeptCount 
						+ "         已配置数:"
						+ myReader.responseJsonObject.configDeptCount
						+ "         未配置数:"
						+ "<font style='font-weight:bold;color:red'>" + myReader.responseJsonObject.notConfigDeptCount, false) + "</font>";
			}
		}
	});

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    文章分类