Commit 8561f5b9 authored by Tristan Cavelier's avatar Tristan Cavelier Committed by Sebastien Robin

Slickgrid can now open document and sort list.

parent 219f5b28
<!DOCTYPE HTML> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
...@@ -22,7 +22,8 @@ ...@@ -22,7 +22,8 @@
<script type="text/javascript"> <script type="text/javascript">
<!-- <!--
(function () { (function () {
var grid, var grid, onSortFunction, onClickFunction,
documentlist = OfficeJS.cloneCurrentDocumentList(),
columns = [ columns = [
{id:"fileName",name:"Document",field:"fileName",sortable:true}, {id:"fileName",name:"Document",field:"fileName",sortable:true},
{id:"lastModified",name:"Modified",field:"lastModified",sortable:true}, {id:"lastModified",name:"Modified",field:"lastModified",sortable:true},
...@@ -39,16 +40,16 @@ ...@@ -39,16 +40,16 @@
$(function () { $(function () {
grid = new Slick.Grid("#myDocumentList", grid = new Slick.Grid("#myDocumentList",
OfficeJS.getCurrentDocumentList(), documentlist,
columns, columns,
options); options);
grid.onSort.subscribe(function (e, args) { onSortFunction = function (e, args) {
var cols = args.sortCols; var cols = args.sortCols;
OfficeJS.getCurrentDocumentList(). documentlist.
sort(function (dataRow1, dataRow2) { sort(function (dataRow1, dataRow2) {
var i, field, sign, value1, value2, result; var i, l, field, sign, value1, value2, result;
for (i = 0, l = cols.length; i < l; i++) { for (i = 0, l = cols.length; i < l; i++) {
field = cols[i].sortCol.field; field = cols[i].sortCol.field;
sign = cols[i].sortAsc ? 1 : -1; sign = cols[i].sortAsc ? 1 : -1;
...@@ -63,7 +64,14 @@ ...@@ -63,7 +64,14 @@
}); });
grid.invalidate(); grid.invalidate();
grid.render(); grid.render();
}); };
onClickFunction = function (e) {
var cell = grid.getCellFromEvent(e);
OfficeJS.open({app:'textEditor',
fileName:documentlist[cell.row].fileName});
};
grid.onClick.subscribe(onClickFunction);
grid.onSort.subscribe(onSortFunction);
}); });
}()); }());
//--> //-->
......
...@@ -302,14 +302,19 @@ ...@@ -302,14 +302,19 @@
}); });
}; };
that.getCurrentDocumentList = function () { that.cloneCurrentDocumentList = function () {
// clone document list // clone document list
var array = $.extend(true,[],priv.data_object.documentList), i; var array = $.extend(true,[],priv.data_object.documentList), i,
lm, cd;
for (i = 0; i < array.length; i += 1) { for (i = 0; i < array.length; i += 1) {
array[i].lastModified = (new Date(array[i].lastModified)). lm = (new Date(array[i].lastModified));
toLocaleString(); cd = (new Date(array[i].creationDate));
array[i].creationDate = (new Date(array[i].creationDate)). array[i].lastModified = lm.getFullYear()+'/'+
toLocaleString(); (lm.getMonth()+1)+'/'+lm.getDate()+' '+
lm.getHours()+':'+lm.getMinutes();
array[i].creationDate = cd.getFullYear()+'/'+
(cd.getMonth()+1)+'/'+cd.getDate()+' '+
cd.getHours()+':'+cd.getMinutes();
} }
return array; return array;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment