如何根据显示方法值隐藏表单网格中的记录?

时间:2017-02-15 23:40:02

标签: forms gridview axapta dynamics-ax-2012 x++

我有一个简单的表单,在我的 DataSource 中我创建了一个经典的displayMethod(名为 calculateAmount )并使用这个metodod在Form的网格中显示值

因此,我们只能显示来自 calculateAmount 的具有特定值的记录,例如我想只显示记录 calculateAmount()> 0,其他记录计算 calculateAmount()< 0没有显示。

所以,如果我不能混合使用Query和displayMethod,可能会在哪里插入条件(例如 active executeQuery 等)?

感谢您的建议。

1 个答案:

答案 0 :(得分:2)

考虑以下顺序:

  1. 调用执行查询并将AOT查询转换为SQL查询
  2. execute query
  3. 之后从SQL Server获取结果
  4. 每条记录调用显示方法,然后在网格
  5. 上显示这些值

    因此,您无法根据显示方法值在executeQuery上添加查询范围

    你可以做的一件事:

    1. 复制数据源表并将其“表类型”属性设置为“TempDB”
    2. if ([your data source].calculateAmount() > 0) { // do not add the record in temp table } else { // add the record in temp table }方法中编写逻辑以填充此新创建的表
    3. 您可以在此处添加以下条件:

      <?php /* Template Name: search info */ get_header(); ?> <?php // code for submit button ation if(isset($_POST['submit'])) { //needed code $site_name=$_POST['site_name']; $owner_name=$_POST['owner_name']; $company_name=$_POST['Company_name']; $Subcontractor_name=$_POST['Subcontractor_name']; ?> <table width="30%" > <tr> <td>Site Name</td> <td>Owner Name</td> <td>Company Name</td> <td>Subcontractor Name</td> </tr> <tr> <td><?php echo $site_name ; ?></td> <td><?php echo $owner_name ; ?></td> <td><?php echo $company_name ; ?></td> <td><?php echo $Subcontractor_name ; ?></td> </tr> </table> <?php } ?> <!--create dropdown list site names--> <form method = "POST" action = ''> <table width="30%"> <tr> <td>Site Name</td> <td>Owner Name</td> <td>Company Name</td> <td>Subcontractor Name</td> </tr> <tr> <td><select id="site_name" name = 'site_name'> <?php $query_site_name =$wpdb->get_results ("select DISTINCT siteNAME from site_info"); foreach($query_site_name as $site_name) { $site_name = (array)$site_name; echo "<option value = '{".$site_name ['siteNAME']."}'>". $site_name['siteNAME']."</option>"; } ?> <!--create dropdown list owner names--> </select></td> <td><select id="owner_name" name = 'owner_name'> <?php $query_owner_name =$wpdb->get_results ("select DISTINCT ownerNAME from owner_info"); foreach($query_owner_name as $owner_name) { $owner_name = (array)$owner_name; echo "<option value = '{".$owner_name ['ownerNAME']."}'>". $owner_name['ownerNAME']."</option>"; } ?> </select></td> <!--create dropdown list Company names--> </select></td> <td><select id="Company_name" name = 'Company_name'> <?php $query_Company_name =$wpdb->get_results ("select DISTINCT companyNAME from company_info"); foreach($query_Company_name as $Company_name) { $Company_name = (array)$Company_name; echo "<option value = '{".$Company_name ['companyNAME']."}'>". $Company_name['companyNAME']."</option>"; } ?> </select></td> <!--create dropdown list Subcontractor names--> </select></td> <td><select id="Subcontractor_name" name = 'Subcontractor_name'> <?php $query_Subcontractor_name =$wpdb->get_results ("select DISTINCT subcontractorNAME from subcontractor_info"); foreach($query_Subcontractor_name as $Subcontractor_name) { $Subcontractor_name = (array)$Subcontractor_name; echo "<option value = '{".$Subcontractor_name ['subcontractorNAME']."}'>". $Subcontractor_name['subcontractorNAME']."</option>"; } ?> </select></td> <tr> <td></td> <td></td> <td></td> <td></td> <td> <input type = "submit" name="submit" value = "Search"> </td> </tr> </table> </form> <?php get_footer(); ?>

    4. 将临时表设置为网格的数据源。

    5. 希望这会有所帮助!!