kra*_*626 5 javascript jquery html-table
如果我有一张桌子:
<table>
<thead>
<tr>Col1</tr>
<tr>Col2</tr>
<tr>Col3</tr>
</thead>
<tbody>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
使用Jquery Ajax从包含数据的tr元素填充tbody的最快,最有效的方法是什么.(除非你有更好的方法)
从webservice返回html代码或在Javascript中动态创建html代码?
此外,我必须支持用户"向下钻取;即,单击一个>或双击该行以打开一个窗格以显示更多信息.(包括另一个表和一个单独的Web服务返回的一些详细信息)
欢迎所有想法!
我在一个使用 jQuery 和 AJAX 的大型企业门户网站上工作。我已经实施jQuery Templates并jQuery TableSorter plug-in促进了这一点。这是一些示例代码:
Javascript(数据提供者):Data.Lists.js
myorg.data.list.GetListItems ({
webURL: "http://our.awesome.portal.com/Lists",
listName: "Projects List",
caml: caml,
CAMLRowLimit: 6,
callback: function(data) {
var list = {};
//code here that formats some data before binding
list.items = data;
var templateHtml = $('.ptMyProjects').html()
.replace("<!--", "").replace("-->","");
var html = $.tmpl(templateHtml, list);
$('.ptMyProjects').html(html);
//make sortable table
$('.ptMyProjects .tablesorter').tablesorter({
sortList: [[0,0]],
headers: {3: {sorter: false}},
widgets: ['zebra']
});
//class last row
$('.ptMyProjects .tablesorter thead th').last().addClass('last');
//add hover effect
$('.ptMyProjects .tablesorter tbody tr, .tablesorter thead .header').hover(function(){
$(this).addClass('hover');
}, function(){
$(this).removeClass('hover');
});
//add tooltips
$('.ptMyProjects .vg_icon').tipsy({gravity: 's'});
}
});
Run Code Online (Sandbox Code Playgroud)
HTML(模板)
<div class="ptMyProjects ptTemplate">
<!--
<table class="tablesorter" border="0" cellpadding="0" cellspacing="0">
<thead>
<tr class="gradient_gray">
<th>Title</th>
<th>Status</th>
<th style="border-right: none;">Progress</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{{if items.length > 0}}
{{each items}}
<tr class='item' recordid="${ows_ID}">
<td ><a class='{{if ows_Critical_x0020_Project == "1"}}critical{{/if}}' href="${DisplayURL}">${ows_Title}</a> </td>
<td class="status">
<a href="#" class="pstatus">${ows_ProjStatus}</a>
<div style='display: none;'>
{{if ows_ProjComments}}
<div style="padding-bottom: 10px;">${ows_ProjComments}</div>
{{/if}}
<div style="font-weight: bold;">Lasted Edited By ${Editor}</div>
<div style="font-style: italic;">${when}</div>
</div>
</td>
<td>
<div class="ui-widget-default">
<div class="progressbar" value="${ows_PercentComplete}" style="height:100%;"></div>
</div>
</td>
<td class="actions">
{{if ows_ProjStatus != "Completed"}}<a href="#" class="vg_icon tick" title="Mark Completed"></a>{{/if}}
<a href="${EditURL}" class="vg_icon pencil" title="Edit"></a>
<a href="#" class="vg_icon comment" title="Comments"></a>
</td>
</tr>
{{/each}}
{{else}}
<tr><td colspan="4">You have no projects.</td></tr>
{{/if}}
</tbody>
</table>
-->
</div>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11232 次 |
| 最近记录: |