0

我有一个名为的子网格TimeTickets,我尝试:

var gridControl = document.getElementById('TimeTickets_d').control;
var ids = gridControl.get_allRecordIds();

但我收到以下错误:

对象不支持属性或方法“get_allRecordIds”

笔记:

  • CRM 汇总更新 13
  • 浏览器:Internet Explorer 9
4

3 回答 3

1

我是这样解决的:

var grid = Xrm.Page.ui.controls.get('TimeTickets')._control;

if (grid.get_innerControl() == null) {
    setTimeout(subGridOnload, 1000);
    return;
}
else if (grid.get_innerControl()._element.innerText.search("Loading") != -1) {
    setTimeout(subGridOnload, 1000);
    return;
}

var ids = grid.get_innerControl().get_allRecordIds();
于 2013-09-02T10:31:30.920 回答
0

正如错误所述,该特定控件不支持 get_allRecordIds 方法。我猜微软可能已经改变了 HTML 的结构,这意味着它没有查看正确的控件。

我建议你改用这个

Xrm.Page.ui.controls.get('TimeTickets')._control.get_innerControl().get_allRecordIds();

编辑正如anykey3 所提到的,这个解决方案似乎也不是一直有效。我让它在 CRM Online 上运行,但是 CRM 内部部署似乎无法正常工作。我有一个可行的解决方案是使用 RESTful 服务,这可能不是最好的解决方案,因为它需要更多代码。

    function GetChildrenValues()
    {
    if (Xrm.Page.data.entity.getId() != null)
    {
        var odataFieldName = "ContactSet";
        var identifier = new Array();
        identifier[0] = Xrm.Page.data.entity.getId();

        var context = Xrm.Page.context;
        var serverUrl = context.getServerUrl();
        var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";

        var odataUri = serverUrl + ODATA_ENDPOINT + "/" + odataSetName + '?$filter=accountid eq {GUID}';


        odataUri +=  '?$filter=accountid eq {GUID}';

        $.ajax({
            type: "GET",
            contentType: "application/json; charset=utf-8",
            datatype: "json",
            url: odataUri,
            beforeSend: function (XMLHttpRequest) {
                //Specifying this header ensures that the results will be returned as JSON.             
                XMLHttpRequest.setRequestHeader("Accept", "application/json");
            },
            success: function (data, textStatus, XmlHttpRequest) {
                SuccessCallback(data, textStatus, XmlHttpRequest);
            },
            error: function (XmlHttpRequest, textStatus, errorThrown) {
                // Handle Error
            }
        });
    }
}

function SuccessCallback(data, textStatus, XmlHttpRequest)
{
    if (data.length > 0) {
        var total = 0;

        for (var i = 0; i < data.length; i++) {
            // Do something
        }
    }
}
于 2013-07-17T00:08:06.213 回答
0

检查此代码在 Dynamics crm 2013 中的工作正常

function RetrieveSubGridRecords() {
debugger;
    if (document.getElementById("Contacts")) {
        var grid = document.getElementById("Contacts").control;
        for (var rowNo = 0; rowNo < grid.GetRecordsFromInnerGrid().length; rowNo++)
            for (var cellNo = 0; cellNo < grid.GetRecordsFromInnerGrid()[rowNo][3].cells.length; cellNo++)
                alert(grid.GetRecordsFromInnerGrid()[rowNo][3].cells[cellNo].outerText);    }    else {
        setTimeout("RetrieveSubGridRecords();", 2500);
    }}
于 2014-06-12T09:49:53.457 回答