婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > asp.net使用jquery模板引擎jtemplates呈現(xiàn)表格

asp.net使用jquery模板引擎jtemplates呈現(xiàn)表格

熱門標簽:宿遷智能外呼系統(tǒng)排名 廣州銷售外呼系統(tǒng)定制 ai電銷機器人對貸款有幫助嗎 電銷機器人 數(shù)據(jù) 400電話辦理信任翰諾科技 云狐人工智能電話機器人 福州人工智能電銷機器人加盟 地圖標注多少錢一張 怎樣給陜西地圖標注顏色

在Asp.net MVC 中,使得我們能夠更加自由控制我們所想顯示HTML。通常情況下,都要做一下數(shù)據(jù)列表。那么我們可以手動去拼一個表格出來,但這樣有時對于復雜的表格說,那就JS代碼比較復雜了。我們可以借助JS下的模板引擎,來實現(xiàn)這一功能。下面要介紹就是JTemplates,它也是基于Jquery的。

復制代碼 代碼如下:

%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
html xmlns="http://www.w3.org/1999/xhtml">
head runat="server">
title>/title>
link href="Content/default.css" rel="stylesheet" type="text/css" />
script src="Scripts/jquery-1.3.1.js" type="text/javascript">/script>
script src="Scripts/jquery-jtemplates.js" type="text/javascript">/script>
script type="text/javascript">
$(document).ready(function() {
$.ajax({
type: "POST",
url: '%=Url.Action("TempleteData", "Home") %>',
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
//instantiate a template with data
ApplyTemplate(msg);

}
});
});
function ApplyTemplate(msg) {
$('#Container').setTemplate($("#TemplateResultsTable").html());
$('#Container').processTemplate(msg);

/script>

/head>
body>
div id="Container"> /div>
%-- Results Table Template --%>
script type="text/html" id="TemplateResultsTable"> 
{#template MAIN} 
table  cellpadding="10" cellspacing="0"> 
 tr> 
th>Username/th> 
th>Password/th> 
th>Url/th> 
th>Email/th> 
th>PassportID/th> 
/tr>
{#foreach$Tasuu}
{#includeROWroot=$T.uu}
{#/for}
/table>
{#/templateMAIN}
{#templateROW}
trclass="{#cyclevalues=['','evenRow']}">
td>{$T.UserName.bold()}/td>
td>{$T.Password}/td>
td>{$T.Url.link($T.Url)}/td>
td>{$T.Email.link('mailto:'+$T.Email)}/td>
td>{$T.PassportID}/td>
/tr>
{#/templateROW}
/script>
/body>
/html>


通過ajax返回json數(shù)據(jù),setTemplate根據(jù)Id設置模板,然后ApplyTemplate就可以了。
CS代碼:
復制代碼 代碼如下:

///summary>
///Templetesthedata.
////summary>
///returns>/returns>
publicJsonResultTempleteData()
{
IListUserEntity>userlist=newListUserEntity>()
{
newUserEntity(){UserName="Tina",PassportID=23433,Email="asdfa@asdf.com",Password="NKASD",Url="http://www.gefds.cn"}
,newUserEntity(){UserName="Lucy",PassportID=3444,Email="2v2@asdf.com",Password="v23sda",Url="http://www.qqfsad.cn"}
};
returnJson(userlist);
}

您可能感興趣的文章:
  • Springboot讀取templates文件html代碼實例
  • 深入淺析springboot中static和templates區(qū)別
  • SpringBoot中關(guān)于static和templates的注意事項以及webjars的配置
  • SpringBoot用JdbcTemplates訪問Mysql實例代碼
  • AngularJs Understanding Angular Templates
  • 詳解Python的Django框架中的templates設置
  • Blitz templates 最快的PHP模板引擎
  • Springboot訪問templates html頁面過程詳解

標簽:大興安嶺 曲靖 宜春 綿陽 延安 黃南 新疆 焦作

巨人網(wǎng)絡通訊聲明:本文標題《asp.net使用jquery模板引擎jtemplates呈現(xiàn)表格》,本文關(guān)鍵詞  asp.net,使用,jquery,模板,引擎,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《asp.net使用jquery模板引擎jtemplates呈現(xiàn)表格》相關(guān)的同類信息!
  • 本頁收集關(guān)于asp.net使用jquery模板引擎jtemplates呈現(xiàn)表格的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 保山市| 若尔盖县| 玉田县| 桑日县| 泸水县| 东光县| 汕头市| 青龙| 玛多县| 汤阴县| 波密县| 海淀区| 淮南市| 常山县| 香河县| 旬阳县| 富宁县| 华容县| 普兰县| 灵川县| 延津县| 卓尼县| 乌苏市| 雷波县| 贞丰县| 岑溪市| 开江县| 马关县| 青川县| 尖扎县| 南乐县| 丹阳市| 乌海市| 修水县| 依兰县| 西林县| 略阳县| 甘孜| 新干县| 惠来县| 云龙县|