【问题标题】:CRM 2016 - Programmatically filtering subgridCRM 2016 - 以编程方式过滤子网格
【发布时间】:2016-10-20 14:06:29
【问题描述】:

我正在尝试按最终客户字段过滤此子网格 ShipmentReportsInformation,以仅显示我当前正在查看的帐户的最终客户记录。现在它正在显示所有这些(不能在表单中使用“仅显示相关记录”,因为它只是文本)。

我在本地使用 Microsoft Dynamics 2016。

所以我制作了一个网络资源(onload 事件),这就是我到目前为止所整理的:

function Filter(){

  var str = Xrm.Page.getAttribute('name').getValue(); //this contains the correct text
  //alert(str); 

  var AllRows = Xrm.Page.getControl("ShipmentReportsInformation").getGrid().getRows(); //all rows inserted in AllRows
  var FilteredRows = AllRows.forEach(function (AllRows, i) {
  if(Xrm.Page.getAttribute('new_endcustomer').getValue() == str){
    FilteredRows.push(AllRows.getData().getEntity().getEntityReference());
  }
//Now I think I should only have the lines added to the FilteredRows variable that match the if condition
  });

  Xrm.Page.getControl("ShipmentReportsInformation").setData(FilteredRows); //putting the data from the var in the subgrid

}

我在编码方面还很陌生,所以,如果我在那里做了一些荒谬的事情,你知道的。 可悲的是,它不起作用,我得到的日志/错误报告根本没有任何帮助。错误和形式,来说明: http://prntscr.com/cwowlf

谁能帮我找出代码中的问题?

我什至认为它是在加载子网格之前加载代码,但我不知道如何正确延迟它。我试过 .getreadystate != complete 但它永远不会完成。

只是为了帮助我到目前为止发现的内容:这是我从以下位置获得大部分信息的地方: -https://msdn.microsoft.com/en-us/library/dn932126.aspx#BKMK_GridRowData

亲切的问候

【问题讨论】:

    标签: javascript forms microsoft-dynamics subgrid


    【解决方案1】:

    虽然这个问题很老,但我试图找到一种过滤子网格的方法并偶然发现了这篇文章。根据 SDK,这就是 setData 方法提到的内容:

    Web 资源有一个名为 data 的特殊查询字符串参数要传递 自定义数据。 getData 和 setData 方法仅适用于 Silverlight 添加到表单的网络资源

    干杯

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-12
      • 2012-03-26
      • 1970-01-01
      • 2018-05-18
      • 1970-01-01
      • 2016-12-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多