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>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
......@@ -22,7 +22,8 @@
<script type="text/javascript">
<!--
(function () {
var grid,
var grid, onSortFunction, onClickFunction,
documentlist = OfficeJS.cloneCurrentDocumentList(),
columns = [
{id:"fileName",name:"Document",field:"fileName",sortable:true},
{id:"lastModified",name:"Modified",field:"lastModified",sortable:true},
......@@ -39,16 +40,16 @@
$(function () {
grid = new Slick.Grid("#myDocumentList",
OfficeJS.getCurrentDocumentList(),
documentlist,
columns,
options);
grid.onSort.subscribe(function (e, args) {
onSortFunction = function (e, args) {
var cols = args.sortCols;
OfficeJS.getCurrentDocumentList().
documentlist.
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++) {
field = cols[i].sortCol.field;
sign = cols[i].sortAsc ? 1 : -1;
......@@ -63,7 +64,14 @@
});
grid.invalidate();
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 @@
});
};
that.getCurrentDocumentList = function () {
that.cloneCurrentDocumentList = function () {
// 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) {
array[i].lastModified = (new Date(array[i].lastModified)).
toLocaleString();
array[i].creationDate = (new Date(array[i].creationDate)).
toLocaleString();
lm = (new Date(array[i].lastModified));
cd = (new Date(array[i].creationDate));
array[i].lastModified = lm.getFullYear()+'/'+
(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;
};
......
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