目标是读取JavaScript中的子网格行,以获取可在以后使用的行的guid。这是在表单的OnLoad
中完成的。
这里有几个问题:
addOnLoad
方法时,它不会在何时调用处理程序
表单是第一次加载。网格必须刷新
或者为它排序以解雇事件。即使我在OnLoad事件中执行代码,它也会在网格中显示零行,尽管Xrm.Page.getControl("Idebarare").getGrid()
不为空。触发时,getTotalRecordCount
返回-1
Xrm.Page.getControl("Idebarare").getGrid().getTotalRecordCount()
这是我目前正在使用的代码。在这里,我从表单的onLoad中调用GetContacts
。
function GetContacts(){
Xrm.Page.getControl("Idebarare").addOnLoad(myContactsGridOnloadFunction);
}
function myContactsGridOnloadFunction(){
var allGridEntities = [];
var rows = Xrm.Page.getControl("Idebarare").getGrid().getRows();
rows.forEach(function (row, i) {
allGridEntities.push(row.getData().getEntity());
});
}
所以问题是如何从动态CRM 2015 Update 1中的JavaScript中的子网格获取属性/ guid的行?