В блоге
The Microsoft Dynamics AX Enterprise Portal Blog предлагается перекрыть методы Pack() и Init() для используемого DataSet'а. Тогда при переходе между страницами и возврате на страницу с данным AxGridView, значение фильтра сохраняется и нет необходимости настраивать фильтр заново.
X++:
public container pack()
{
container ret;
SysLastValue sysLastValue;
formdatasource filterDataSource;
;
filterDataSource = SalesTable_ds; // Put your datasource name
ttsbegin;
// Delete last saved query for the current dataset
delete_from sysLastValue
where sysLastValue.Company == curext()
&& sysLastValue.UserId == curuserid()
&& sysLastValue.RecordType == UtilElementType::DataSet
&& sysLastValue.ElementName == filterDataSource.name()
&& sysLastValue.DesignName == filterDataSource.name();
// If there is a new queryRun() object then serialize and save it
// in the sys last value table
// Put your datasource name
if (filterDataSource.queryRun())
{
sysLastValue.RecId = 0;
sysLastValue.Company = curext();
sysLastValue.UserId = curuserid();
sysLastValue.RecordType = UtilElementType::DataSet;
sysLastValue.ElementName = filterDataSource.name();
sysLastValue.DesignName = filterDataSource.name();
sysLastValue.value = SysQuery::packRangeAndSortorder(filterDataSource.queryRun().query());
sysLastValue.insert();
}
ttscommit;
ret = super();
return ret;
}
X++:
public void init()
{
SysLastValue sysLastValue;
Query savedQuery;
;
super();
// get the last value from the sys last value table
select firstonly sysLastValue
where sysLastValue.Company == curext()
&& sysLastValue.UserId == curuserid()
&& sysLastValue.RecordType == UtilElementType::DataSet
&& sysLastValue.ElementName == this.name()
&& sysLastValue.DesignName == this.name();
if (sysLastValue && sysLastValue.Value)
{
// If there is an unpack error delete the saved query
if (!SysQuery::unpackRangeAndSortorder(this.query(), sysLastValue.value))
{
ttsbegin;
delete_from sysLastValue
where sysLastValue.Company == curext()
&& sysLastValue.UserId == curuserid()
&& sysLastValue.RecordType == UtilElementType::DataSet
&& sysLastValue.ElementName == this.name()
&& sysLastValue.DesignName == this.name();
ttscommit;
}
}
}