I started school on Monday, and I went back to retake the logistics test. If you don't talk much about it, just go to the code. Well, there are four lines, but you can see that it is still one line .. [Javascript] varmyTablenewTable ({title: & amp; #39; University for four years & amp; #39;, data: data,... syntaxHi started school on Monday and went back to retake logistics.
If you don't talk much about it, just go to the code. Well, there are four lines, but you can see that it is still one line ..
[Javascript] var myTable = new Table ({
Title: 'four years of university ',
Data: data,
Thead: thead
});
Data is the data in the table. We don't need to say anything about thead.
Data is the data in the table. We don't need to say anything about thead.
[Javascript] var data = [
['Sad ', 'Eat', 'Sleep ', 'playing play', 'learn Java', 'Watch this world'],
['Sad ', 'Eat', 'Sleep ', 'playing play', 'learn Java', 'Watch this world'],
['Sad ', 'Eat', 'Sleep ', 'playing play', 'learn Java', 'Watch this world'],
['Sad ', 'Eat', 'Sleep ', 'playing play', 'learn Java', 'Watch this world']
]
Var thead = ['heading 1', 'heading 2', 'heading 3', 'heading 4', 'heading 5', 'heading 6']
Var data = [
['Sad ', 'Eat', 'Sleep ', 'playing play', 'learn Java', 'Watch this world'],
['Sad ', 'Eat', 'Sleep ', 'playing play', 'learn Java', 'Watch this world'],
['Sad ', 'Eat', 'Sleep ', 'playing play', 'learn Java', 'Watch this world'],
['Sad ', 'Eat', 'Sleep ', 'playing play', 'learn Java', 'Watch this world']
]
Var thead = ['heading 1', 'heading 2', 'heading 3', 'heading 4', 'heading 5', 'heading 6']
Of course, every time you want to create such a table in a row, you need to encapsulate it. The Code is as follows. It is very random to write, without careful scrutiny, comments, and error tolerance, come on.
The Ext table that is obviously imitated.
[Javascript]
[Javascript] myExt = {};
MyExt. util = {};
MyExt.util.css = {};
MyExt.util.css. applyCss = function (src ){
Var link = document. createElement ('link ')
Link. rel = "stylesheet ";
Link. type = 'text/css ';
Link. href = src;
Document. getElementsByTagName ('head') [0]. appendChild (link );
};
Function Table (config ){
This. title = config. title;
This. data = config. data;
This. thead = config. thead;
This. show ();
}
Table. prototype. show = function (){
Var table = document. createElement ('table ');
Var tbody = document. createElement ('tbody ');
Var cap = document. createElement ('caption ');
Cap. appendChild (document. createTextNode (this. title ));
Table. appendChild (cap );
Table. appendChild (tbody );
Var thead = document. createElement ('tr ');
Tbody. appendChild (thead );
For (var m = 0; this. thead [m]; m ++ ){
Var th = document. createElement ('th ');
Th. appendChild (document. createTextNode (this. thead [m]);
Thead. appendChild (th );
}
Var rows = this. data. length;
Var cols = this. data [0]. length;
For (var I = 0; I
Var tr = document. createElement ('tr ');
Tbody. appendChild (tr );
For (var j = 0; j
If (j ){
Var td = document. createElement ('td ');
Td. appendChild (document. createTextNode (this. data [I] [j]);
Tr. appendChild (td );
} Else {
Var td = document. createElement ('th ');
Td. appendChild (document. createTextNode (this. data [I] [j]);
Tr. appendChild (td );
}
}
}
MyExt.util.css.applyCss('table.css ');
Document. body. appendChild (table );
}
Var data = [
['Sad ', 'Eat', 'Sleep ', 'playing play', 'learn Java', 'Watch this world'],
['Sad ', 'Eat', 'Sleep ', 'playing play', 'learn Java', 'Watch this world'],
['Sad ', 'Eat', 'Sleep ', 'playing play', 'learn Java', 'Watch this world'],
['Sad ', 'Eat', 'Sleep ', 'playing play', 'learn Java', 'Watch this world']
]
Var thead = ['heading 1', 'heading 2', 'heading 3', 'heading 4', 'heading 5', 'heading 6']
Var myTable = new Table ({
Title: 'four years of university ',
Data: data,
Thead: thead
});
MyExt = {};
MyExt. util = {};
MyExt.util.css = {};
MyExt.util.css. applyCss = function (src ){
Var link = document. createElement ('link ')
Link. rel = "stylesheet ";
Link. type = 'text/css ';
Link. href = src;
Document. getElementsByTagName ('head') [0]. appendChild (link );
};
Function Table (config ){
This. title = config. title;
This. data = config. data;
This. thead = config. thead;
This. show ();
}
Table. prototype. show = function (){
Var table = document. createElement ('table ');
Var tbody = document. createElement ('tbody ');
Var cap = document. createElement ('caption ');
Cap. appendChild (document. createTextNode (this. title ));
Table. appendChild (cap );
Table. appendChild (tbody );
Var thead = document. createElement ('tr ');
Tbody. appendChild (thead );
For (var m = 0; this. thead [m]; m ++ ){
Var th = document. createElement ('th ');
Th. appendChild (document. createTextNode (this. thead [m]);
Thead. appendChild (th );
}
Var rows = this. data. length;
Var cols = this. data [0]. length;
For (var I = 0; I
Var tr = document. createElement ('tr ');
Tbody. appendChild (tr );
For (var j = 0; j
If (j ){
Var td = document. createElement ('td ');
Td. appendChild (document. createTextNode (this. data [I] [j]);
Tr. appendChild (td );
} Else {
Var td = document. createElement ('th ');
Td. appendChild (document. createTextNode (this. data [I] [j]);
Tr. appendChild (td );
}
}
}
MyExt.util.css.applyCss('table.css ');
Document. body. appendChild (table );
}
Var data = [
['Sad ', 'Eat', 'Sleep ', 'playing play', 'learn Java', 'Watch this world'],
['Sad ', 'Eat', 'Sleep ', 'playing play', 'learn Java', 'Watch this world'],
['Sad ', 'Eat', 'Sleep ', 'playing play', 'learn Java', 'Watch this world'],
['Sad ', 'Eat', 'Sleep ', 'playing play', 'learn Java', 'Watch this world']
]
Var thead = ['heading 1', 'heading 2', 'heading 3', 'heading 4', 'heading 5', 'heading 6']
Var myTable = new Table ({
Title: 'four years of university ',
Data: data,
Thead: thead
}); [Javascript]
[Javascript]
[Javascript]
Finally, I will give you a canvas pie chart of pure js and forget the flash.
From songzheng_741