2013-10-28 83 views
2

我創建了一個服務,該服務將根據請求參數返回一組HTML表格。目前,我將數據(HTML頁面)作爲字符串返回。樣本輸出低於:使用HTML表格作爲數據源將數據綁定到Kendo UI模板

<!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字符串返回,我想每個表莫名其妙地綁定到劍道UI的網格。如何才能做到這一點?如果沒有,那麼這樣做的正確方法是什麼?

回答

3

我不知道這是否是你想要什麼,但你可以注入該HTML到您的網頁(我的例子使用jQuery的)

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

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

然後把所有的表到劍道網格:

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

您是否碰巧知道如何獲取類以及可能在原始行和單元格上設置的其他屬性,並將其傳輸到新表中? Kendo似乎將它們全部取代,這意味着桌面標記本身傳輸的信息會丟失。 – John

相關問題