0

我对 Javascript 中的 XMLDocument 对象有疑问。它未定义或为空。我的 aspx 代码是

<div id='tabs_<%= RowId %>_2'>
    <table id='hist_<%= RowId %>'> //RowID is a number
     </table>
     <xml id='hist_data_<%= RowId %>'> //RowID is a number
        <%= GridData.ToString() %> //i have data in datagrid with xml format.
     </xml>
 </div>

我的脚本是

 function showCall(row_id){
    $("#hist_" + row_id).jqGrid({
    datatype: "xmlstring",
    datastr: document.all("hist_data_" + row_id).XMLDocument.xml // XMLDocument is undefined or null        
    });
}

我们大部分的客户使用IE9或更早版本的IE9。所以我在兼容模式下在 IE9 中调试。不太确定,因为一些文档/博客建议从 IE9 中删除 XMLDocument。谁能建议我解决这个问题的最佳方法?

编辑:

GridData xml 设置 - C# 背后的代码

 GridData = new XDocument(new XElement("root", rows = new XElement("rows")));
    foreach (Chronos.Messaging.CallStatus cs in Call.StatusList)
    {
        long s = cs.Duration;
        string duration = "";
        if (s > 0)
            duration = String.Format(@"{0:m:ss}", new DateTime(s * 10000000));
        bool rec = !String.IsNullOrEmpty(cs.MessageId);
        double rating = Admin ? WebServiceHelper.GetWebService().getCallRating(cs.ID) : 0;
        rows.Add(
            new XElement("row",
                new XElement("cell", cs.Timestamp.ToString("dd/MM/yy HH:mm:ss")),
                new XElement("cell", cs.AgentName),
                new XElement("cell", cs.Incoming ? (char)0x2713 : ' '), // 0x2713 is tick mark
                new XElement("cell", TelephoneNumberFormatter.Number(cs.NumberCalled)),
                new XElement("cell", duration),
                new XElement("cell", rec & !survey ? "<a href='Listen.aspx?id=" + cs.MessageId + "'>" + cs.DialResultDescription + "</a>" : cs.DialResultDescription),
                new XElement("cell", survey ? "" : cs.Info),
                new XElement("cell", rating > 0 ? String.Format(@"<input type=""button"" value=""{0} %"" onclick=""window.open('CallRating.aspx?callStatusID={1}&callID={2}','Rating','status=1,resizable=1,scrollbars=1,width=590,height=650');return false;"" />", rating.ToString(), cs.ID, Call.ID) : String.Format(@"<input type=""button"" value=""Rate"" onclick=""window.open('CallRating.aspx?callStatusID={0}&callID={1}','Rating','status=1,resizable=1,scrollbars=1,width=590,height=650');return false;"" />", cs.ID, Call.ID))
                ));
    }
4

0 回答 0