对SubGrid中的数据进行进一步筛选
通常在一个主Form中会有一个普通字段和子网格(subgrid)。
例如:主表单中有一个客户字段(N:1),子网格中的数据与客户也有关联(N:1)。
当主Form中的客户字段变更时对应的子网格中的数据也需要跟着刷新。
假如主Form中的客户字段选择为(中国银行)则子网格中的所有数据中的客户也必须都为(中国银行)。
对此有两种解决方案:
1:当主Form中的客户字段变更时直接刷新subgrid。对subgrid的刷新事件追加以下操作。
对subgrid追加刷新事件
在onLoad时追加如下代码来对subgrid追加refresh事件
SubgridRefresh = function () {
//取得subgrid
var yardmototype= document.getElementById("yardmototype");
if (yardmototype== null) {
//1second后重新调用
setTimeout("SubgridRefresh ()", 1000);
} else {
yardmototype.control.add_onRefresh(function () {
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"
+ "<entity name='new_yardmototype'>"
+ " <attribute name='new_yardmototypeid' />"
+ " <attribute name='new_number' />"
+ " <attribute name='createdon' />"
+ " <order attribute='new_number' descending='false' />"
+ " <filter type='and'>"
+ " <condition attribute='statecode' operator='eq' value='0' />"
+ " <condition attribute='new_custname' operator='eq' uitype='account' value='{D85136EB-A1AE-E511-80DA-005056AD06D3}' />"
+ " </filter>"
+ "</entity>"
+ "</fetch>";
//Set the fetchxml directly to subgrid
yardmototype.control.SetParameter("fetchXml", fetchXml); //set the fetch xml to the sub grid
yardmototype.control.Refresh(); //refresh the sub grid using the new fetch xml
});
}
}
“`
2.注册一个Retrievemultiple 的插件,将传入进来的query表达式替换为实际业务需要的。但是这种情况下需要区分是哪种情况下触发的Retrievemultiple插件。