Posted in Javascript onOctober 25, 2016
本文实例讲述了jQuery+json实现动态创建复杂表格table的方法。分享给大家供大家参考,具体如下:
function SetSubTable() { var obj = jQuery.parseJSON($("#SubJsonStrValue").val()); window.ALLPARAMTERS = obj; var row_str = ""; var span_num = 1 for (var i = 0; i < obj.length; i++) { if (obj[i].ParamNames.length > 0) { row_str += '<tr><td rowspan="' + obj[i].ParamNames.length + '"><input type="checkbox" name="_'+obj[i].Id+'" />' + obj[i].Name + '</td>'; for (var j = 0; j < obj[i].ParamNames.length; j++) { if (j != 0) { row_str += "<tr>"; } row_str += '<td><input type="checkbox" name="p_'+obj[i].ParamNames[j].Id+'_'+obj[i].Id+'" />' + obj[i].ParamNames[j].Name + '</td><td>'; for (var k = 0; k < obj[i].ParamNames[j].ListItems.length; k++) { row_str += obj[i].ParamNames[j].ListItems[k].Name+"|"; } row_str = row_str.substring(0, row_str.length - 2); row_str += "</td><td>"; if (obj[i].ParamNames[j].CanMultiSelecte) { row_str += "多选"; } else { row_str += "单选"; } row_str += "</td></tr>"; } } } $("#sub_table_header").after(row_str); }
jQuery+json实现动态创建复杂表格table的方法
- Author -
liulun声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@