【问题标题】:Kendo UI grid widget XML data source content not displayedKendo UI 网格小部件 XML 数据源内容未显示
【发布时间】:2016-06-11 13:19:02
【问题描述】:

我对剑道的东西有点了解,因此我正在寻求你的帮助。 我正在尝试使用 xml 数据显示剑道网格​​。但是网格的行显示为空。我正在尝试从 url(http://demos.kendoui.com/service/Northwind.svc/Products) 获取数据并在 kendo 小部件上设置数据源。一旦我运行示例 (http://jsfiddle.net/visibleinvisibly/c3qsdjq0/19/) 它显示空网格。我相信这种情况正在发生,因为我无法在数据源的“模式”对象中设置“数据”属性。我不想在这个示例中使用 json

以下是示例 Xml 数据

<feed xml:base="http://demos.telerik.com/kendo-ui/service/Northwind.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
    .............................
    ...........................
  <entry>
   ..................
    ....................
    <content type="application/xml">
      <m:properties>
        <d:ProductID m:type="Edm.Int32">1</d:ProductID>
        <d:ProductName>Chai</d:ProductName>
        <d:UnitPrice m:type="Edm.Decimal">18.00</d:UnitPrice>    
      </m:properties>
    </content> 
     </entry>
  </feed>

schema中的data属性是这样设置的

schema: {
 type: "xml",
 data: "/feed/entry/content/properties",
 model: {
         fields: {
            ProductID: "ProductID/text()",
            ProductName: "ProductName/text()",
            UnitPrice: "UnitPrice/text()"
         }
     }
 }

提前致谢,

亚历克斯。

【问题讨论】:

    标签: xml kendo-ui kendo-grid


    【解决方案1】:

    @Alex - 下面是我的分析 -

    第 1 点 - 未显示数据

    当我尝试在 chrome 中运行您的 jsfiddle 示例 (http://jsfiddle.net/visibleinvisibly/c3qsdjq0/19/) 时,控制台中出现以下错误 -

    "XMLHttpRequest cannot load http://demos.kendoui.com/service/Northwind.svc/Products?take=10&skip=0&page=1&pageSize=10. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://fiddle.jshell.net' is therefore not allowed access."
    

    这清楚地表明了内容未显示在您的 Kendo UI 网格中的原因。

    第 2 点 - 使用 XML

    我尝试使用 AngularJS 使用 XML 类型,但出现以下错误-

    "Unknown DataSource transport type 'xml'.
    Verify that registration scripts for this type are included after Kendo UI on the page."
    

    我相信,这意味着它们是 XML 作为数据源传输类型不能使用。您将不得不依赖 JSON 或 OData。

    希望这会有所帮助!

    干杯 卫生巾

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-17
      • 2016-08-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多