29.08.2009, 04:49 | #1 |
Участник
|
Solutions Monkey: Persisting Filter conditions in EP Grid
Источник: http://blogs.msdn.com/solutions/arch...n-ep-grid.aspx
============== Persisting Filter condition in EP Grid In AX 2009, EP grid control comes with an advanced filter. Here is a code to persist the filter condition the user last entered in a page for that user, so that later when the user comes back to the same page the last filter is applied and user didn’t have to reenter then. This code sample assumes a dataset with the name “EPSalesTableList” which contains the datasource “SalesTable” (1) First override the pack method of the dataset ( EPSalesTableList in this example) in AOT 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; } (2) Second override the init method of the datasource ( SalesTable in this example) within that dataset in AOT 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; } } } Make sure you replace the datasourcename variable filterDataSource in the pack method with your datasource name.Save the changes, refresh AOD and now go to the page that is using this dataset and enter some filter condition & apply. Close the browser and reopen the page. Now you should see that the filter that you last applied before the browser was closed is still applied in this page. Arif Kureshy, who is the dev manager for EP came out with his code snippet. So thanks to him for providing this sample code. ============== Источник: http://blogs.msdn.com/solutions/arch...n-ep-grid.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
|