|
|
@@ -52,10 +52,10 @@ xhttp.send("fname=Henry&lname=Ford");
|
|
|
|
|
|
function DatabaseGrid()
|
|
|
{
|
|
|
- this.editableGrid = new EditableGrid("demo", {
|
|
|
+ this.editableGrid = new EditableGrid("dptape", {
|
|
|
enableSort: true,
|
|
|
// define the number of row visible by page
|
|
|
- pageSize: 50,
|
|
|
+ pageSize: 10,
|
|
|
// Once the table is displayed, we update the paginator state
|
|
|
tableRendered: function() { updatePaginator(this); },
|
|
|
tableLoaded: function() { datagrid.initializeGrid(this); },
|
|
|
@@ -69,7 +69,8 @@ function DatabaseGrid()
|
|
|
|
|
|
DatabaseGrid.prototype.fetchGrid = function() {
|
|
|
// call a PHP script to get the data
|
|
|
- this.editableGrid.loadJSON("loaddata");
|
|
|
+ this.editableGrid.loadJSON("/loaddata");
|
|
|
+ //this.editableGrid.loadJSON("/static/loaddata.json");
|
|
|
};
|
|
|
|
|
|
DatabaseGrid.prototype.initializeGrid = function(grid) {
|
|
|
@@ -79,28 +80,28 @@ DatabaseGrid.prototype.initializeGrid = function(grid) {
|
|
|
// render for the action column
|
|
|
grid.setCellRenderer("action", new CellRenderer({
|
|
|
render: function(cell, id) {
|
|
|
- cell.innerHTML+= "<i onclick=\"datagrid.deleteRow("+id+");\" class='fa fa-trash-o red' ></i>";
|
|
|
+ cell.innerHTML+= "<i onclick=\"datagrid.deleteRow('"+grid.getRowId(cell.rowIndex)+"');\" class='fa fa-trash-o red' ></i> <i onclick=\"datagrid.duplicate('" + grid.getRowId(cell.rowIndex) + "');\" class='fa fa-files-o' ></i>";
|
|
|
}
|
|
|
- }));
|
|
|
+ }));
|
|
|
|
|
|
-
|
|
|
- grid.renderGrid("tablecontent", "testgrid");
|
|
|
+ grid.renderGrid("tablecontent", "table table-bordered table-striped table-fixed-header");
|
|
|
+
|
|
|
};
|
|
|
|
|
|
+// functions below are untested
|
|
|
DatabaseGrid.prototype.deleteRow = function(id)
|
|
|
{
|
|
|
|
|
|
var self = this;
|
|
|
-
|
|
|
- if ( confirm('Are you sur you want to delete the row id ' + id ) ) {
|
|
|
+
|
|
|
+ if ( confirm('Are you sure you want to delete the row id ' + id ) ) {
|
|
|
|
|
|
$.ajax({
|
|
|
- url: 'delete',
|
|
|
+ url: '/write_delete',
|
|
|
type: 'POST',
|
|
|
dataType: "html",
|
|
|
data: {
|
|
|
- tablename : self.editableGrid.name,
|
|
|
- mongoid: editableGrid.getRowId(rowIndex),
|
|
|
+ mongoid: id,
|
|
|
},
|
|
|
success: function (response)
|
|
|
{
|
|
|
@@ -113,8 +114,8 @@ DatabaseGrid.prototype.deleteRow = function(id)
|
|
|
|
|
|
|
|
|
}
|
|
|
-
|
|
|
-};
|
|
|
+};
|
|
|
+
|
|
|
|
|
|
|
|
|
DatabaseGrid.prototype.addRow = function(id)
|
|
|
@@ -123,13 +124,23 @@ DatabaseGrid.prototype.addRow = function(id)
|
|
|
var self = this;
|
|
|
|
|
|
$.ajax({
|
|
|
- url: 'add.php',
|
|
|
+ url: '/write_insert',
|
|
|
type: 'POST',
|
|
|
dataType: "html",
|
|
|
data: {
|
|
|
- tablename : self.editableGrid.name,
|
|
|
- name: $("#name").val(),
|
|
|
- firstname: $("#firstname").val()
|
|
|
+ 'Date': $("#Date").val(),
|
|
|
+ Date2: $("#Date2").val(),
|
|
|
+ Titel: $("#Titel").val(),
|
|
|
+ Languages: $("#Languages").val(),
|
|
|
+ Country: $("#Country").val(),
|
|
|
+ City: $("#City").val(),
|
|
|
+ Place: $("#Place").val(),
|
|
|
+ Category: $("#Category").val(),
|
|
|
+ Duration: $("#Duration").val(),
|
|
|
+ Location: $("#Location").val(),
|
|
|
+ Format: $("#Format").val(),
|
|
|
+ Note: $("#Note").val(),
|
|
|
+ Status: $("#Status").val(),
|
|
|
},
|
|
|
success: function (response)
|
|
|
{
|
|
|
@@ -139,6 +150,19 @@ DatabaseGrid.prototype.addRow = function(id)
|
|
|
showAddForm();
|
|
|
$("#name").val('');
|
|
|
$("#firstname").val('');
|
|
|
+ $("#Date").val(''),
|
|
|
+ $("#Date2").val(''),
|
|
|
+ $("#Titel").val(''),
|
|
|
+ $("#Languages").val(''),
|
|
|
+ $("#Country").val(''),
|
|
|
+ $("#City").val(''),
|
|
|
+ $("#Place").val(''),
|
|
|
+ $("#Category").val(''),
|
|
|
+ $("#Duration").val(''),
|
|
|
+ $("#Location").val(''),
|
|
|
+ $("#Format").val(''),
|
|
|
+ $("#Note").val(''),
|
|
|
+ $("#Status").val(''),
|
|
|
|
|
|
alert("Row added : reload model");
|
|
|
self.fetchGrid();
|
|
|
@@ -207,17 +231,4 @@ function showAddForm() {
|
|
|
$("#addform").hide();
|
|
|
else
|
|
|
$("#addform").show();
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+};
|