AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 29.08.2009, 04:49   #1  
Blog bot is offline
Blog bot
Участник
 
25,643 / 848 (80) +++++++
Регистрация: 28.10.2006
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, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Solutions Monkey: Integrating EP Web Parts to non-EP SharePoint sites Blog bot DAX Blogs 0 04.04.2009 03:19
Solutions Monkey: Deploying Ax 2009 SP1 EP Blog bot DAX Blogs 0 05.02.2009 07:08
Solutions Monkey: EP SSL ( https) Setup Blog bot DAX Blogs 0 23.10.2008 12:05
Solutions Monkey: EP Deployment - Internals Blog bot DAX Blogs 0 21.10.2008 20:05
Solutions Monkey: How to alternate the background color of each row in Web Grid in EP 4.0? Blog bot DAX Blogs 0 12.01.2008 12:31

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 07:53.