html - 使用 HTML Table 作为数据源将数据绑定(bind)到 Kendo UI Template

标签 html telerik kendo-ui datasource

我创建了一个服务,它将根据请求参数返回一组 HTML 表格。目前,我将数据(HTML 页面)作为字符串返回。示例输出如下:

<!DOCTYPE html>
<html>
   <head>
      <META http-equiv="Content-Type" content="text/html; charset=utf-8">
   </head>
   <body>
      <h1>Person</h1>
      <table name="name">
         <thead>
            <tr>
               <th data-field="propertyID"> Property ID</th>
               <th data-field="property"> Property</th>
               <th data-field="valueID"> Value ID</th>
               <th data-field="value"> Value</th>
            </tr>
         </thead>
         <tr>
            <td>http://topbraid.org/examples/kennedys#name</td>
            <td>Name</td>
            <td>Alfred Tucker</td>
            <td>Alfred Tucker</td>
         </tr>
      </table>
      <table name="firstName">
         <thead>
            <tr>
               <th data-field="propertyID"> Property ID</th>
               <th data-field="property"> Property</th>
               <th data-field="valueID"> Value ID</th>
               <th data-field="value"> Value</th>
            </tr>
         </thead>
         <tr>
            <td>http://topbraid.org/examples/kennedys#firstName</td>
            <td>First Name</td>
            <td>Alfred</td>
            <td>Alfred</td>
         </tr>
      </table>
      <table name="lastName">
         <thead>
            <tr>
               <th data-field="propertyID"> Property ID</th>
               <th data-field="property"> Property</th>
               <th data-field="valueID"> Value ID</th>
               <th data-field="value"> Value</th>
            </tr>
         </thead>
         <tr>
            <td>http://topbraid.org/examples/kennedys#lastName</td>
            <td>Last Name</td>
            <td>Tucker</td>
            <td>Tucker</td>
         </tr>
      </table>
      <table name="gender">
         <thead>
            <tr>
               <th data-field="propertyID"> Property ID</th>
               <th data-field="property"> Property</th>
               <th data-field="valueID"> Value ID</th>
               <th data-field="value"> Value</th>
            </tr>
         </thead>
         <tr>
            <td>http://topbraid.org/examples/kennedys#gender</td>
            <td>Gender</td>
            <td>http://topbraid.org/examples/kennedys#male</td>
            <td>male</td>
         </tr>
      </table>
      <table name="birthYear">
         <thead>
            <tr>
               <th data-field="propertyID"> Property ID</th>
               <th data-field="property"> Property</th>
               <th data-field="valueID"> Value ID</th>
               <th data-field="value"> Value</th>
            </tr>
         </thead>
         <tr>
            <td>http://topbraid.org/examples/kennedys#birthYear</td>
            <td>Birth Year</td>
            <td>1967</td>
            <td>1967</td>
         </tr>
      </table>
      <table name="spouse">
         <thead>
            <tr>
               <th data-field="propertyID"> Property ID</th>
               <th data-field="property"> Property</th>
               <th data-field="valueID"> Value ID</th>
               <th data-field="value"> Value</th>
            </tr>
         </thead>
         <tr>
            <td>http://topbraid.org/examples/kennedys#spouse</td>
            <td>Spouce</td>
            <td>http://topbraid.org/examples/kennedys#KymSmith</td>
            <td>Kym Smith</td>
         </tr>
      </table>
      <table name="type">
         <thead>
            <tr>
               <th data-field="propertyID"> Property ID</th>
               <th data-field="property"> Property</th>
               <th data-field="valueID"> Value ID</th>
               <th data-field="value"> Value</th>
            </tr>
         </thead>
         <tr>
            <td>http://www.w3.org/1999/02/22-rdf-syntax-ns#type</td>
            <td>Type</td>
            <td>http://topbraid.org/examples/kennedys#Person</td>
            <td>Person</td>
         </tr>
      </table>
   </body>
</html>

现在我得到了 HTML 字符串,我想以某种方式将每个表绑定(bind)到 Kendo UI 中的网格。如何才能做到这一点?如果不是,那么正确的方法是什么?

最佳答案

我不确定这是否正是您想要的,但您可以将该 HTML 注入(inject)到您的页面中(我的示例使用 jQuery)

<div id="contentArea"></div>

$("#contentArea").html(serviceResult);

然后将所有 table 变成剑道网格:

$("#contentArea table").kendoGrid({});

关于html - 使用 HTML Table 作为数据源将数据绑定(bind)到 Kendo UI Template,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19642967/

相关文章:

html - CSS 中的条件注释

c# - 修改从 ObjectDataSource 返回的集合

stored-procedures - 使用存储过程时使用 Telerik MVC 网格进行分页

kendo-ui - 如何对齐右手边的剑道网格工具栏

javascript - Kendo Grid 行更改(未选中)时是否有事件?

javascript - 即使在浏览器恢复模式下也能获得浏览器的原始宽度和高度

html - 如何在 Bootstrap 中调整我的输入表单的长度

javascript - 剑道网格 : how to use a column template so editor always available?

html - 有没有一种简单的方法可以将 Markdown 转换为漂亮的 html 文档,包括导航?

javascript - Telerik RadConfirm 不适用于 asp.net 的 UserControls