我想从 json 数据中为菜单项构建子菜单。
菜单
<div class="subnav-fixed" id="menuContrainer" runat="server">
<ul class="nav nav-pills">
<li id="Li0"><a href="Default.aspx">Home </li>
<li id="Li1"><a href="InitiativeGrid.aspx">Initiative</a></li>
<li id="Li2"><a href="Reports.aspx">Reports</a></li>
<li id="Li3"><a href="EditInitiative.aspx">Edit Initiatives</a></li>
</ul>
</div>
JSON
data =
"{"d":[
{"__type":"Tableau_Reports:#CostReductionData",
"ClientIdx":1,
"GroupName":"HR",
"ReportGroup":"1",
"ReportHeight":"800",
"ReportName":"Baseline Vs Active Employees",
"ReportOrder":"0",
"ReportUrl":"https://company.com/t/sga/views/HRReports/BaselineandActiveEmployees"
},
{"__type":"Tableau_Reports:#CostReductionData",
"ClientIdx":1,
"GroupName":"HR",
"ReportGroup":"1",
"ReportHeight":"800",
"ReportName":"Level vs Direct Reports",
"ReportOrder":"0",
"ReportUrl":"https://company.com/t/sga/views/HRReports/LevelvsDirectReports"
},
{"__type":"Tableau_Reports:#Alixpartners.SGACostReductionData",
"ClientIdx":1,
"GroupName":"Finance",
"ReportGroup":"2",
"ReportHeight":"800",
"ReportName":"Spans and Layers",
"ReportOrder":"0",
"ReportUrl":"https://company.com/t/sga/views/HRReports/SpansandControl"
}]
}"
我想像这样显示报告菜单项的子菜单
Home Initiative Reports Edit Initiative
|
HR- Baseline Vs Active Employees
- Level vs Direct Reports
|
Finance - Spans and Layers
我们如何用 Jquery 做到这一点?