① first uses C # in the background to get the menu data in the database, to generate a JSON array containing the menu data items (for some reason not using the order by in SQL), as follows:
View Sourceprint?var menudata1=[
{"OrderID": -10, "text": "Home", "title": "Personal website home page", "url": "Default.aspx?" teacherid=153 "," visible ": true," target ":" _self "},
{" OrderID ": Ten," text ":" Personal News "," title ":" Personal News "," url ":" News.aspx? teacherid=153 "," visible ": true," target ":" _self "},
{" OrderID ": 5," text ":" Publish Paper "," title ":" Publish a paper "," url ":" Paper.aspx? teacherid=153 "," visible ": true," target ":" _self "},
{" OrderID ": 2," text ":" Publication Monograph "," title ":" Publication monograph "," url ":" Monograph.aspx? teacherid=153 "," visible ": true," target ":" _self "},
{" OrderID ": 7," text ":" Participating in Project "," title ":" Participating in Project "," url ":" Project.aspx? teacherid=153 "," visible ": true," target ":" _self "},
{" OrderID ": 8," text ":" Personal Honor "," title ":" Personal Honor "," url ":" Prize.aspx? teacherid=153 "," visible ": true," target ":" _self "},
{" OrderID ": 1," text ":" Invention Patent "," title ":" Invention Patent "," url ":" Patent.aspx? teacherid=153 "," visible ": true," target ":" _self "},
{" OrderID ": 0," text ":" File Share "," title ":" File Share "," url ":" Fileshare.aspx? teacherid=153 "," visible ": true," target ":" _self "}
];
② you need to sort the array in OrderID ascending order first, note that the sort method overwrites the original array
View Sourceprint?menudata1.sort (function (A, b) {return a.orderid > B.orderid 1:-1;}); /
After the ③ has been sorted, the result is:
View sourceprint?menudata1=[
{"OrderID": -10, "text": "Home", "title": "Personal site Home page", "url": "Default.aspx?" teacherid=153 "," visible ": true," target ":" _self "},
{" OrderID ": 0," text ":" File Share "," title ":" File Share "," url ":" Fileshare.aspx? teacherid=153 "," visible ": true," target ":" _self "},
{" OrderID ": 1," text ":" Invention Patent "," title ":" Invention Patent "," url ":" Patent.aspx? teacherid=153 "," visible ": true," target ":" _self "},
{" OrderID ": 2," text ":" Publication Monograph "," title ":" Publication monograph "," url ":" Monograph.aspx? teacherid=153 "," visible ": true," target ":" _self "},
{" OrderID ": 5," text ":" Publish Paper "," title ":" Publish a paper "," url ":" Paper.aspx? teacherid=153 "," visible ": true," target ":" _self "},
{" OrderID ": 7," text ":" Participating in Project "," title ":" Participating in Project "," url ":" Project.aspx? teacherid=153 "," visible ": true," target ":" _self "},
{" OrderID ": 8," text ":" Personal Honor "," title ":" Personal Honor "," url ":" Prize.aspx? teacherid=153 "," visible ": true," target ":" _self "},
{" OrderID ": Ten," text ":" Personal News "," title ":" Personal News "," url ":" News.aspx? teacherid=153 "," visible ": true," target ":" _self "}
];
④ then displays the Visual menu item based on the Menudata1[i].visible property (where String.Format see Implementing a string in JavaScript like C #. Features of format):
The Visual menu item is then displayed based on the Menudata1[i].visible property (where String.Format see "Implementing a string in JavaScript like C #." Features of format):
var menustring = "<ul><li class=" Menudiv "></li>";
for (Var i=0;i<menudata1.length;i++) {
if (menudata1[i].visible) {
Menustring + + String.Format ("<li><a title=" {0} "class=" Menua "onfocus=" This.blur () "href=" {1} "target=" {2} " >{3}</a></li><li class= "Menudiv" ></li> ", Menudata1[i].title, Menudata1[i].url, Menudata1[i].target, Menudata1[i].text);
}
}
menustring = "</ul>";
$ (menucontainer). InnerHTML = menustring;