如何为动态表添加标题 [英] How to add header for dynamic table
本文介绍了如何为动态表添加标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好我正在绘制动态表,我想为表添加标题如何将标题添加到动态表中这里是我的表代码:
< code $ $ .get('http://myDomain.com/RIA/topIndiaDetails.asp',function(data)
{
console.log(####+ data );
var up = new Image();
var down = new Image();
up.src =../../jquery .mobile / images / up.png;
down.src =../../jquery.mobile/images/down.png
substr = data.split(' $');
//alert (substr.length);
// var theader ='< table border =1> \\\
';
//< table id =auditOverviewborder =1>
var theader ='< table border =1id = \tableId\> \\\
';
var tbody ='';
for(var out = 1; out< substr.length-1; out ++)
{
// alert(substr [out ]);
tbody + ='< tr>';
var pra = substr [out] .split('| ^');
(var i = 0; i< pra.length-1; i ++)
{
tbody + ='< td>';
if(pra [i] ==Red)
{
pra [i] .append(< img id ='theImg'src ='.. /../jquery.mobile/images/down.png'/>);
}
else if(pra [i] ==Green)
{
pra [i] .append(< img id ='theImg'src =' ../../jquery.mobile/images/up.png'/>);
}
tbody + = pra [i];
tbody + ='< / td>'
}
tbody + ='< / tr> \ n';
}
var tfooter ='< / table>';
document.getElementById('wrapper')。innerHTML = theader + tbody + tfooter;
});
任何帮助将不胜感激。
解决方案
如果我能正确理解你的观点,那么
DEMO : http://jsfiddle.net/75zFX/8/
var colheader ='< tr>< th> Column1< th> Column2< th> .....< / TR> \\\
;
var tbody = colheader; //并用var tbody =''替换;
Hello everybody I am drawing dynamic table and I want to add header for table how to add header to dynamic table here is my table code:
$.get('http://myDomain.com/RIA/topIndiaDetails.asp', function(data)
{
console.log("####"+data);
var up = new Image();
var down = new Image();
up.src = "../../jquery.mobile/images/up.png";
down.src = "../../jquery.mobile/images/down.png"
substr = data.split('$');
//alert(substr.length);
//var theader = '<table border="1">\n';
//<table id="auditOverview" border="1">
var theader = '<table border="1" id=\"tableId\">\n';
var tbody = '';
for (var out = 1;out<substr.length-1;out++)
{
//alert(substr[out]);
tbody += '<tr>';
var pra = substr[out].split('|^');
//alert('pra.length is: '+pra.length);
for (var i=0;i<pra.length-1;i++)
{
tbody += '<td>';
if (pra[i]=="Red")
{
pra[i].append("<img id='theImg' src='../../jquery.mobile/images/down.png'/>");
}
else if (pra[i]=="Green")
{
pra[i].append("<img id='theImg' src='../../jquery.mobile/images/up.png'/>");
}
tbody += pra[i];
tbody += '</td>'
}
tbody += '</tr>\n';
}
var tfooter = '</table>';
document.getElementById('wrapper').innerHTML = theader + tbody + tfooter;
});
Any help will be appreciated. Thanks in advance.
解决方案
if I could get your point correctly
DEMO: http://jsfiddle.net/75zFX/8/
var colheader = '<tr><th>Column1</th><th>Column2</th> .....</tr>\n';
var tbody = colheader ;// and replace with var tbody = '';
这篇关于如何为动态表添加标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文