ReportViewer 15.0.0 Визуализация: Sys.ArgumentNullException: значение не может быть нулевым. Имя параметра: элемент - PullRequest
1 голос
/ 26 июня 2019

У меня возникает следующая проблема с отображением отчета (с определенным набором параметров) с использованием MS ReportViewer. JS, вызванный из внутреннего JS-кода ReportViewer, не работает, в частности, этот раздел «ScriptResource.axd»:

var $addHandlers = Sys.UI.DomEvent.addHandlers = function Sys$UI$DomEvent$addHandlers(element, events, handlerOwner, autoRemove) {
    /// <summary locid="M:J#Sys.UI.DomEvent.addHandlers" />
    /// <param name="element"></param>
    /// <param name="events" type="Object"></param>
    /// <param name="handlerOwner" optional="true"></param>
    /// <param name="autoRemove" type="Boolean" optional="true"></param>
    var e = Function._validateParams(arguments, [
        {name: "element"},
        {name: "events", type: Object},
        {name: "handlerOwner", optional: true},
        {name: "autoRemove", type: Boolean, optional: true}
    ]);
    if (e) throw e;
    Sys.UI.DomEvent._ensureDomNode(element);
    for (var name in events) {
        var handler = events[name];
        if (typeof(handler) !== 'function') throw Error.invalidOperation(Sys.Res.cantAddNonFunctionhandler);
        if (handlerOwner) {
            handler = Function.createDelegate(handlerOwner, handler);
        }
        $addHandler(element, name, handler, autoRemove || false);
    }
}

"Sys.UI.DomEvent._ensureDomNode (element);" сбой линии со следующей ошибкой:

Sys.ArgumentNullException: значение не может быть нулевым. Имя параметра: элемент

Когда я просматриваю трассировку стека:

enter image description here

Похоже, что источником этой проблемы является JS, вызываемый с главной страницы "Отчета":

Sys.Application.add_init(function() {
    $create(Microsoft.Reporting.WebFormsClient._Splitter, {"HoverStyle":"SplitterHover","ImageCollapse":"/Reserved.ReportViewerWebControl.axd?OpType=Resource\u0026Version=15.0.900.148\u0026Name=Microsoft.Reporting.WebForms.Icons.SplitterHorizCollapse.png","ImageCollapseHover":"/Reserved.ReportViewerWebControl.axd?OpType=Resource\u0026Version=15.0.900.148\u0026Name=Microsoft.Reporting.WebForms.Icons.SplitterHorizCollapseHover.png","ImageExpand":"/Reserved.ReportViewerWebControl.axd?OpType=Resource\u0026Version=15.0.900.148\u0026Name=Microsoft.Reporting.WebForms.Icons.SplitterHorizExpand.png","ImageExpandHover":"/Reserved.ReportViewerWebControl.axd?OpType=Resource\u0026Version=15.0.900.148\u0026Name=Microsoft.Reporting.WebForms.Icons.SplitterHorizExpandHover.png","ImageId":"ctl00_ApplicationBody_rvReport_ToggleParam_img","IsCollapsable":true,"NormalStyle":"SplitterNormal","Resizable":false,"StoreCollapseField":"ctl00_ApplicationBody_rvReport_ToggleParam_collapse","StorePositionField":"ctl00_ApplicationBody_rvReport_ToggleParam_store","TooltipCollapse":"Hide Parameters","TooltipExpand":"Show Parameters","Vertical":false}, null, null, $get("ctl00_ApplicationBody_rvReport_ToggleParam"));
});

Это нарушение обработанного отчета. Я не уверен, как отследить это дальше, я знаю, что вы можете получить отчет для форматирования с другими параметрами, но я не понимаю, как можно отлаживать минимизированный JS, внутренний для библиотеки ReportViewer.

Является ли этот сбой JS известной проблемой для определенных отчетов? Я использую последнюю версию библиотеки (15.0.0). Я бы опубликовал и отчет, и параметры, однако они содержат конфиденциальную информацию. Как устранить неполадки, внутренние для библиотеки ReportViewer, для решения таких проблем, как эта?

1 Ответ

0 голосов
/ 04 июля 2019

Очень хитро, у меня был метод C #, запущенный в MasterPage, отключающий некоторые типы управления, чтобы пользователь не мог «редактировать» страницу, выглядело это примерно так:

//CommonFunctions
public static List<T> GetAllControlsRecursiveByType<T>(ControlCollection Controls) where T : Control
{
    List<T> results = new List<T>();
    foreach (Control c in Controls)
    {
        if (c is T)
        {
            results.Add((T)c);
        }

        if (c.HasControls())
        {
            results.AddRange(GetAllControlsRecursiveByType<T>(c.Controls));
        }
    }
    return results;
}

public void DisableControls(Control control)
{
    if (control == null)
    {
        return;
    }

    DisableControl(control);
    foreach (System.Web.UI.Control c in control.Controls)
    {
        DisableControl(c);

        // Recurse into child controls.
        if (c.Controls.Count > 0)
        {
            DisableControls(c);
        }
    }
}

foreach (Control element in CommonFunctions.GetAllControlsRecursiveByType<Control>(FindControl("ApplicationBody").Controls))
{
    List<string> excludedIDs = new List<string>() { "btnAjaxDynamicFilterApplyFilter", "btnClose", "btnCancel", "btnExport" };
    List<Type> includedTypes = new List<Type>() { typeof(LinkButton), typeof(Button), typeof(ImageButton), typeof(Repeater), typeof(ABC.Controls.ABCRepeater),
        typeof(GridView), typeof(ABC.Controls.ABCGridView), typeof(ABC.Controls.ImageCheckBox) };

    if (!excludedIDs.Contains(element.ID) && includedTypes.Contains(element.GetType()))
    {
        DisableControls(element);
    }
}

Оказывается, это было«Отключение» определенных визуализированных элементов управления в средстве просмотра отчетов, в свою очередь, приводило к поломке JS во внешней части.Я исправил это, исключив «ReportViewer» из этой логики:

public bool ControlHasParentWithType(Control control, Type type)
{
    if (control == null || control.Parent == null)
    {
        return false;
    }
    else if (control.Parent.GetType() == type)
    {
        return true;
    }

    return ControlHasParentWithType(control.Parent, type);
}

//Within Method before disabling the control
if (ControlHasParentWithType(element, typeof(ReportViewer)))
{
    continue;
}
...