Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build script and ommitting of columns for joTable #45

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ jsmin < jo.js > jo_min.js
# echo "Compiling jo.js -> jo_com.js"
# java -jar ~/bin/compiler.jar --js=jo.js --js_output_file=jo_com.js
# gzip -c jo_com.js > jo_com.js.gz
cd ..
echo "Done."

if [[ ${1} && -d ${1} ]]; then
echo "Copying files to test directory"
cp jo.js jo_min.js ${1}
fi

cd ..
echo "Done compiling."
26 changes: 23 additions & 3 deletions js/ui/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,41 @@
- `getRow()`, `getCol()`

Return the current row or column

- `setOmitCols(array)`

Sets the columns whose header is in the passed array be omited.

*/

joTable = function(data) {
this.omitCols = new Array();
this.omitIndex = new Array();
joList.apply(this, arguments);
};

joTable.extend(joList, {
tagName: "jotable",

// With another round of formatItem as overhead because of refresh()
setOmitCols: function(omitArray){
this.omitCols = omitArray;
this.refresh();
},

// default row formatter
formatItem: function(row, index) {
var tr = document.createElement("tr");

for (var i = 0, l = row.length; i < l; i++) {
var o = document.createElement(index ? "td" : "th");

if ((this.omitCols.indexOf(row[i]) != -1)) {
this.omitIndex.push(i);
}

if (this.omitIndex.indexOf(i%l) > -1) continue;

o.innerHTML = row[i];

// this is a little brittle, but plays nicely with joList's select event
Expand Down Expand Up @@ -88,6 +109,5 @@ joTable.extend(joList, {
var rowsize = this.data[0].length;

return index % rowsize;
}
}
});