日期:2014-05-16  浏览次数:20452 次

ExtJS store中如何获取action的返回值作为参数

var st_measureUnit = new Ext.data.Store({
baseParams : {
start : 0,
limit : ????(存在问题的地方)
  },
url : 'unitType/findAllUnitType.action',
reader : .....(省略)
});
这是一个读取远程的store,设置了两个参数:start和limit,想读取getCount这个action的返回值作为参数limit的值,应该如何写?


public int getTotalCount() {
return totalCount;
}
getTotalCount函数是unitType/getCount.action所对应的方法

------解决方案--------------------
在当前页面中设置个hidden的input存放你的totalCount变量(每次action返回的时候重置一下input的值);
然后再JS中用var limit = document.getElementById('name').value取值,
limit :limit
这样就可以了吧。
------解决方案--------------------
'beforeload': function (store, options) {
var params = {
order: store.getSortString(),
page: store.currentPage,
limit: store.pageSize
};
Ext.apply(store.proxy.extraParams, params);
}

在beforeload事件中,定义一个params的json对象,里面的limit可以自己定义值,然后apply到store.proxy.extraParams里面去即可!