Skip to content

Commit 2962541

Browse files
committed
Updated documentation in the Table class
1 parent d8316db commit 2962541

File tree

1 file changed

+55
-19
lines changed

1 file changed

+55
-19
lines changed

src/table/Table.js

Lines changed: 55 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,24 @@ javaxt.dhtml.Table = function(parent, config) {
2525

2626
var defaultConfig = {
2727

28+
29+
/** If true, the table will allow users to select multiple rows using
30+
* control or shift key. Default is false (only one row is selected at
31+
* a time).
32+
*/
2833
multiselect: false,
34+
35+
36+
/** If true, the table will render a vertical scrollbar, allowing users
37+
* to scroll up/down and see rows that are out of view. If false, the
38+
* scrollbar is hidden from view. Default is true.
39+
*/
2940
overflow: true,
3041

42+
43+
/** Style for individual elements within the component. Note that you can
44+
* provide CSS class names instead of individual style definitions.
45+
*/
3146
style: {
3247

3348
table: {
@@ -83,17 +98,20 @@ javaxt.dhtml.Table = function(parent, config) {
8398
},
8499

85100

86-
iscroll: null //If null or false, uses inline style. If "custom",
87-
//uses, "iScrollHorizontalScrollbar", "iScrollVerticalScrollbar",
88-
//and "iScrollIndicator" classes. You can also define custom class
89-
//names by providing a style map like this:
90-
/*
101+
/** Style for iScroll (if present). If the style is set to null or
102+
* false, uses inline style. If a "custom" keyword is given, will
103+
* use "iScrollHorizontalScrollbar", "iScrollVerticalScrollbar",
104+
* and "iScrollIndicator" classes defined in your css. You can also
105+
* define custom class names by providing a style map like this:
106+
<pre>
91107
iscroll: {
92108
horizontalScrollbar: "my-iScrollHorizontalScrollbar",
93109
verticalScrollbar: "my-iScrollVerticalScrollbar",
94110
indicator: "my-iScrollIndicator"
95111
}
96-
*/
112+
</pre>
113+
*/
114+
iscroll: null
97115
}
98116
};
99117

@@ -480,7 +498,13 @@ javaxt.dhtml.Table = function(parent, config) {
480498
//**************************************************************************
481499
/** Appends multiple rows to the table. On some browsers (e.g. iPad) this
482500
* method is significantly faster than calling addRow() multiple times.
483-
* Example: table.addRows([["Bob","12/30","$5.25"],["Jim","10/28","$7.33"]]);
501+
* Example:
502+
<pre>
503+
table.addRows([
504+
["Bob","12/30","$5.25"],
505+
["Jim","10/28","$7.33"]
506+
]);
507+
</pre>
484508
*/
485509
this.addRows = function(rows){
486510

@@ -520,9 +544,14 @@ javaxt.dhtml.Table = function(parent, config) {
520544
//** addRow
521545
//**************************************************************************
522546
/** Appends a row to the table and populates the cells with given values.
523-
* Example: table.addRow("Bob","12/30","$5.25");
524-
* Note that this method also accepts an array of values.
525-
* Example: table.addRow(["Bob","12/30","$5.25"]);
547+
* Example:
548+
<pre>
549+
table.addRow("Bob","12/30","$5.25");
550+
</pre>
551+
* Note that this method also accepts an array of values. Example:
552+
<pre>
553+
table.addRow(["Bob","12/30","$5.25"]);
554+
</pre>
526555
*/
527556
this.addRow = function(){
528557

@@ -913,12 +942,16 @@ javaxt.dhtml.Table = function(parent, config) {
913942
//**************************************************************************
914943
//** onKeyEvent
915944
//**************************************************************************
945+
/** Called whenever a keyboard event is initiated from the table.
946+
*/
916947
this.onKeyEvent = function(keyCode, modifiers){};
917948

918949

919950
//**************************************************************************
920951
//** focus
921952
//**************************************************************************
953+
/** Used to set browser focus on the table.
954+
*/
922955
this.focus = function(){
923956
bodyDiv.parentNode.focus();
924957
};
@@ -942,15 +975,12 @@ javaxt.dhtml.Table = function(parent, config) {
942975
//**************************************************************************
943976
//** update
944977
//**************************************************************************
945-
/** Called whenever rows are added or removed from the table.
978+
/** Used to refresh the scroll bars. This method is called internally
979+
* whenever rows are added or removed from the table.
946980
*/
947981
this.update = function(){
948-
949-
950-
me.onOverflow(me.hasOverflow());
951-
952-
953982
if (me.iScroll) me.iScroll.refresh();
983+
me.onOverflow(me.hasOverflow());
954984
};
955985

956986

@@ -1053,9 +1083,13 @@ javaxt.dhtml.Table = function(parent, config) {
10531083
//**************************************************************************
10541084
//** getScrollInfo
10551085
//**************************************************************************
1086+
/** Returns scroll position and dimenstions for the visible area.
1087+
*/
10561088
this.getScrollInfo = function(){
10571089
return {
1090+
x: me.iScroll ? -me.iScroll.x : bodyDiv.scrollLeft,
10581091
y: me.iScroll ? -me.iScroll.y : bodyDiv.scrollTop,
1092+
w: bodyDiv.offsetWidth,
10591093
h: bodyDiv.offsetHeight,
10601094
maxY: bodyDiv.scrollHeight - bodyDiv.clientHeight
10611095
};
@@ -1077,9 +1111,11 @@ javaxt.dhtml.Table = function(parent, config) {
10771111
//**************************************************************************
10781112
/** Used to traverse all the rows in the table and extract contents of each
10791113
* cell. Example:
1080-
* table.forEachRow(function (row, content) {
1081-
* console.log(content);
1082-
* });
1114+
<pre>
1115+
table.forEachRow(function (row, content) {
1116+
console.log(content);
1117+
});
1118+
</pre>
10831119
*
10841120
* Optional: return true in the callback function if you wish to stop
10851121
* processing rows.

0 commit comments

Comments
 (0)