2014-03-06 142 views
0

我目前正在使用Microsoft Dynamics AX中的表单。 表格由来自4个不同表格的约10个字段的网格组成。 由于表单现在返回太多的值,所以我需要包括某种过滤器,它不需要是动态的,只是一个静态过滤器,只表示列Y中的值为X的行。添加表单过滤器

这里有人有这种事情的一些经验吗?我从哪说起呢?

我必须说我没有使用Microsof AX,所以我一直在使用它一个月左右。

我试着按照这个指南:How to: Add Filter Controls to a Simple List Form [AX 2012] 但我被困在第二部分(要添加一个控件到自定义过滤器组)第2步:我不知道选择哪种类型的控件,我ik我选择让我们说一个组合框我不能得到第3步工作,因为我没有看到他们提到的'覆盖方法'。

回答

1

嗯,我通常做这种方式:

  • 在ClassDeclaration,创造尽可能多QueryBuildRanges变量字段进行过滤。让我们为它们命名标准1,Criteria2等(他们的名字正确,请,还不如在这里)

    QueryBuildRange criteria1, criteria2; 
    
  • 在每一个你要过滤数据源,覆盖方法Init,附加代码与此类似:

    super(); 
    criteria1 = this.query().datasource(tablenum(tableofdatasource)).addQueryRange(fieldNum(fieldtofilter)) 
    //criteria1.status(RangeStatus::locked); //optional - this way you can hide filter field to user, have it readonly for users, etc 
    
  • 在表单中创建一个类型为StringEdit或ListBox的控件用作过滤器。将他们的AutoDeclaration属性更改为Yes。覆盖modified()方法。在这里面,我用它来把类似的东西:

    super(); 
    element.changeFilters(); 
    
  • 在形式上,添加方法changeFilters();

    range rangeFromStringControl = StringEditControlName.text(); //Put in rangeFromStringControl the string to be used as filter, as a user would write it 
    range rangeFromListBoxControl; 
    criteria1.value(rangeFromStringControl); 
    
    switch (listBoxControl.Selection()) 
    { 
        case NoYesAll::All: 
         rangeFromListBoxControl = ''; //Empty filter string - No filter at all 
         break; 
        case NoYesAll::No: 
         rangeFromListBoxControl = QueryValue(NoYes::No); //Or whatever string filter value you want 
         break; 
        //Etc 
    } 
    
    //We have all filter strs done; let's filter for each main DataSource required with new filters 
    DataSource1.executeQuery(); 
    //If there is other datasources joined to this one, it's usually no necessary to call their executeQuery; 
    //If there are others with filters and not joined to it, call their executeQuery() 
    
  • 如果需要此滤波器时的形式是开放的应用,设置appropiate初始值对照,然后在形式的run()方法:

    run(); 
    element.changeFilters();