【发布时间】: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