Documentation

EditTable Class

General Public Methods

Method Description Remarks Example
Init() EditTable object initialisation   var myET = new EditTable('myTableId');
myET.editable = true;
...
myET.Init();
GetCellsNb( rowIndex ) returns number of cells of a specified row   myET.GetCellsNb(4);
GetRowsNb() returns total number of rows   myET.GetRowsNb();
GetRow(e) returns the DOM row element for a given event   function myFunction(e){ var clickedRow = myET.GetRow(e); }
GetRowByIndex( rowIndex ) returns the DOM row element for a given row index   myET.GetRowByIndex(5);
GetCell(e) returns the DOM cell element for a given event   function myFunction(e){ var clickedCell = myET.GetCell(e); }
IsSelectable() checks if table rows are selectable and returns a boolean   myET.IsSelectable();
IsEditable() checks if table is editable and returns a boolean   myET.IsEditable();
ClearSelections() clears current row(s) and/or cell selection   myET.ClearSelections();
Top of page

Selection Public Methods

Method Description Remarks Example
Init() Selection object initialisation   var myET = new EditTable('myTableId');
...
myET.Selection.Init();
Set() enables selection feature   myET.Selection.Set();
Remove() disables selection feature   myET.Selection.Remove();
SetEvents() sets click and keyboard events to table element   myET.Selection.SetEvents();
RemoveEvents() removes click and keyboard events to table element   myET.Selection.RemoveEvents();
GetActiveRow() returns the active row element, that is, the row currently selected   var activeRow = myET.Selection.GetActiveRow();
if(activeRow){ ... }
GetActiveCell() returns the active cell element, that is, the cell currently selected   var activeCell = myET.Selection.GetActiveCell();
if(activeCell){ ... }
GetSelectedRows() returns an array of the row elements currently selected, if selection model is multiple returns:
[rowobject, rowobject, rowobject, ... rowobject]
var selRows = myET.Selection.GetSelectedRows();
if(selRows.length > 0){ ... }
GetSelectedValues() returns an array containing a collection of selected rows values returns: [
['value 0', 'value 1', 'value 2', ... 'value 3'],
['value 0', 'value 1', 'value 2', ... 'value 3'],
['value 0', 'value 1', 'value 2', ... 'value 3'],
...
['value 0', 'value 1', 'value 2', ... 'value 3']
]
var selValues = myET.Selection.GetSelectedValues();
if(selValues.length > 0){
var firstValueOfFirstSelectedRow = selValues[0][0];
}
GetActiveRowValues() returns an array containing the cell values of active row returns ['value 0', 'value 1', 'value 2', ... 'value 3'] var activeValues = myET.Selection.GetActiveRowValues();
if(activeValues.length > 0){ ... }
GetRowValues( row ) returns an array containing the cell values of a given row, it accepts only a row DOM element returns ['value 0', 'value 1', 'value 2', ... 'value 3']

var myRow = myET.GetRowByIndex(7);
if(myRow){
myRowValues = myET.Selection.GetRowValues(myRow);
}

SelectRowByIndex( rowIndex ) selects a row for a given row index   myET.Selection.SelectRowByIndex(9);
SelectRowsByIndexes( rowIndexes ) new selects rows for a given array of row indexes Multiple selection needs to be active (selection_model: 'multiple') myET.Selection.SelectRowsByIndexes([2, 7, 9, 12]);
SelectRow( row ) selects given row element   var myRow = myET.GetRowByIndex(6);
if(myRow){
myET.Selection.SelectRow(myRow);
}
DeselectRow( row ) deselects given row element   var myRow = myET.GetRowByIndex(6);
if(myET.Selection.IsRowSelected(myRow)){
myET.Selection.DeselectRow(myRow);
}
SelectCell( cell ) selects given cell element   var myCell = myET.GetRowByIndex(3).cells[2];
if(myCell) myET.Selection.SelectCell(myCell);
DeselectCell( cell ) deselects given cell element   var myCell = myET.GetRowByIndex(3).cells[2];
if(myCell) myET.Selection.DeselectCell(myCell);
ClearSelections() clears current row(s) and/or cell selection The general ClearSelections() invokes this method ( myET.ClearSelections() ) myET.Selection.ClearSelections();
IsRowSelected( row ) determines if given row is selected and returns a boolean   var myRow = myET.GetRowByIndex(6);
if(myET.Selection.IsRowSelected(myRow)){ ... }
IsCellSelected( cell ) determines if given cell is selected and returns a boolean   var myCell = myET.GetRowByIndex(3).cells[2];
if(myET.Selection.IsCellSelected( myCell )){ ... }
Top of page

Editable Public Methods

Method Description Remarks Example
Init() Editable object initialisation   var myET = new EditTable('myTableId');
...
myET.Editable.Init();
Set() enables inline editing feature   myET.Editable.Set();
Remove() disables inline editing feature   myET.Editable.Remove();
SetEvents() sets click and keyboard events to table element   myET.Editable.SetEvents();
RemoveEvents() removes click and keyboard events to table element   myET.Editable.RemoveEvents();
GetModifiedRows() returns an array containing the modified rows objects returns:
[
[rowIndex,
{ values: [val0, val1, ...valn],
urlParams: '&ColName0=cellvalue0&ColName1=cellvalue1',
modified: [true, false, ...]
}],
...
[rowIndex,
{ values: [val0, val1, ...valn],
urlParams: '&ColName0=cellvalue0&ColName1=cellvalue1',
modified: [true, false, ...]
}]
]
urlParams are the paramaters names that are expected server-side. If the parameters' names are not defined by the property param_names in the actions object (configuration object actions), the param name by default equals to 'col_n' where n is the column index (col_0, col_1, ... col_n)

var modRowObjs = myET.Editable.GetModifiedRows();
for(var i=0; i<modRowObjs.length; i++){
var rowIndex = modRowObjs[i][0]; //int
var obj = modRowObjs[i][1]; //object
var objValues = obj.values; //array
var objModValues = obj.modified; //array of booleans
var objUrlParams = obj.urlParams //string
}

GetAddedRows() returns an array containing the added rows objects returns:
[
[rowIndex,
{ values: [val0, val1, ...valn],
urlParams: '&ColName0=cellvalue0&ColName1=cellvalue1',
modified: [true, true, ...]
}],
...
[rowIndex,
{ values: [val0, val1, ...valn],
urlParams: '&ColName0=cellvalue0&ColName1=cellvalue1',
modified: [true, true, ...]
}]
]
urlParams are the paramaters names that are expected server-side. If the parameters' names are not defined by the property param_names in the actions object (configuration object actions), the param name by default equals to 'col_n' where n is the column index (col_0, col_1, ... col_n)
var addRowObjs = myET.Editable.GetAddedRows();
for(var i=0; i<addRowObjs.length; i++){
var rowIndex = addRowObjs[i][0]; //int
var obj = addRowObjs[i][1]; //object
var objValues = obj.values; //array
var objModValues = obj.modified; //array of booleans
var objUrlParams = obj.urlParams //string
}
GetDeletedRows() returns an array containing the deleted rows objects returns:
[
[rowIndex,
{ values: [val0, val1, ...valn],
urlParams: '&ColName0=cellvalue0&ColName1=cellvalue1',
modified: [false, false, ...]
}],
...
[rowIndex,
{ values: [val0, val1, ...valn],
urlParams: '&ColName0=cellvalue0&ColName1=cellvalue1',
modified: [false, false, ...]
}]
]
urlParams are the paramaters names that are expected server-side. If the parameters' names are not defined by the property param_names in the actions object (configuration object actions), the param name by default equals to 'col_n' where n is the column index (col_0, col_1, ... col_n)
var delRowObjs = myET.Editable.GetDeletedRows();
for(var i=0; i<delRowObjs.length; i++){
var rowIndex = delRowObjs[i][0]; //int
var obj = delRowObjs[i][1]; //object
var objValues = obj.values; //array
var objModValues = obj.modified; //array of booleans
var objUrlParams = obj.urlParams //string
}
SubmitEditedRows() submits edited rows to server according to actions configuration options modified rows objects are sent to server (uri property in 'update' actions configuration options)

function SaveEditedRows(){
myET.Editable.SubmitEditedRows();
}

SubmitAddedRows() submits added rows to server according to actions configuration options added rows objects are sent to server (uri property in 'insert' actions configuration options) function SaveAddedRows(){ myET.Editable.SubmitAddeddRows(); }
SubmitDeletedRows() submits deleted rows to server according to actions configuration options deleted rows objects are sent to server (uri property in 'delete' actions configuration options). A confirmation prompt appears before sending data to server

function DeleteSelectedRows(){ myET.Editable.SubmitDeletedRows(); }

SubmitAll() new submits added and edited rows to server according to actions configuration options function SubmitAll(){ myET.Editable.SubmitAll(); }
AddNewRow() adds a row to the table myET.Editable.AddNewRow();