Demos
DEMO 2
This demo shows how to- configure the cell editors and enable the command buttons for editing
- configure the server-side actions for insert, update and delete operations
- plug a custom date picker component and use the editor's delegates
- use custom cell data validators
- use server activity callbacks to display a loader
- implement a custom row tooltip by using the row selection callback events
- customise the script's messages
This demo and demo 1 use the same SQL table, but here records flagged as deleted are also displayed.
Please note that is a live demo and your tests will be recorded in a database!
Instructions: double-click on a cell to open the row editor.
| Id | Name | Start Date | Salary | Deleted | Actions | |
|---|---|---|---|---|---|---|
| 53266 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53265 | DANYEL PINO | employee@email.com | 2011-01-07 | 0.00 | ||
| 53264 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53263 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53262 | NAME | employee@email.com | 2011-01-01 | 0.00 | ||
| 53261 | JUAN DANYEL | employee@email.com | 2011-01-01 | 0.00 | ||
| 53260 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53259 | Employee name... | employee@email.com | 2011-01-02 | 0.00 | ||
| 53258 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53257 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53256 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53255 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53254 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53253 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53252 | sfgsdfgsdfgdg | employee@email.com | 2012-01-01 | 0.00 | ||
| 53251 | ertert | employee@email.com | 2012-01-01 | 0.00 | ||
| 53250 | gdgafg | employee@email.com | 2012-01-01 | 0.00 | ||
| 53249 | Employee name... | employee@email.com | 2012-01-01 | 0.00 | ||
| 53248 | Employee name... | employee@email.com | 2012-01-01 | 0.00 | ||
| 53247 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53246 | Employee name... | employee@email.com | 2010-12-03 | 0.00 | ||
| 53245 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53244 | REY | employee@email.com | 2011-01-20 | 0.00 | ||
| 53243 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53242 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53241 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53240 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53239 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53238 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53237 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53236 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53235 | dfg sdfg | employee@email.com | 2011-01-01 | 0.00 | ||
| 53234 | sdfg sdfgsdfg sdfgsdfg | employee@email.com | 2011-01-01 | 0.00 | ||
| 53233 | dfgsdf sdfg | employee@email.com | 2011-01-01 | 0.00 | ||
| 53232 | John Doe | employee@email.com | 2011-01-01 | 0.00 | ||
| 53231 | dfgsdfg sdfgsdfg | employee@email.com | 2011-01-07 | 0.00 | ||
| 53230 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53229 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53228 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53227 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53226 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53225 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53224 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53223 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53222 | Employee name... | employee@email.com | 2007-04-18 | 0.00 | ||
| 53221 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53220 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53219 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53218 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53217 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53216 | hjkhkHUhu | employee@email.com | 2011-01-01 | 0.00 | ||
| 53215 | ccvcvcv | employee@email.com | 2011-01-01 | 0.00 | ||
| 53214 | Test me | employee@email.com | 2011-01-01 | 0.00 | ||
| 53213 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53212 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53211 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53210 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53209 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53208 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53207 | Capot | jmsosa77@hotmail.com | 2011-01-01 | 0.00 | ||
| 53206 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53205 | efsdf | employee@email.com | 2011-01-13 | 0.00 | ||
| 53204 | Jose | jmsosa77@hotmail.com | 2011-01-01 | 0.00 | ||
| 53203 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53202 | fefsdf | employee@email.com | 2011-01-01 | 0.00 | ||
| 53201 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53200 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53199 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53198 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53197 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53196 | capot | employee@email.com | 2011-01-01 | 0.00 | ||
| 53195 | JUAN PEREZ PEREZ | employee@email.com | 2011-01-01 | 0.00 | ||
| 53194 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53193 | JULIAN JOSEPTH | julianjoseh@email.com | 2011-01-01 | 0.00 | ||
| 53192 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53191 | Employee name... | employee@email.com | 2012-01-01 | 0.00 | ||
| 53190 | test | employee@email.com | 2011-01-01 | 0.00 | ||
| 53189 | test2 | employee@email.com | 2011-01-01 | 0.00 | ||
| 53188 | test | employee@email.com | 2011-01-01 | 0.00 | ||
| 53187 | testbbb | employee@email.l | 2011-01-01 | 0.00 | ||
| 53186 | asdfasdf | employee@email.com | 2018-01-07 | 2.23 | ||
| 53185 | dfd | employee@email.com | 2011-01-01 | 0.00 | ||
| 53184 | fgfgf | employee@email.com | 2011-01-01 | 0.00 | ||
| 53183 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53182 | hjgfvih uyoiug oi hoil | employee@email.com | 2011-01-01 | 0.00 | ||
| 53181 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53180 | Employee name... | employee@email.com | 2011-01-12 | 0.00 | ||
| 53179 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53178 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53177 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53176 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53175 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53174 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53173 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53172 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53171 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53170 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53169 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53168 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
| 53167 | Employee name... | employee@email.com | 2011-01-01 | 0.00 |
//ezEditTable configuration object
var demo2Config = {
editable: true,
scroll_into_view: true,
form_submit_interval: 900,
auto_save: false,
cell_editors:[
{ type: 'none' },
{ type: 'input', attributes:[['title', 'First name and last name']], allow_empty_value:true },
{ type: 'input', attributes:[['title', 'email address']] },
{ type: 'custom', target: 'dateEditor' },
{ type: 'input', attributes:[['maxLength', 9], ['title', '9 digits max.']], css:'alignRight' },
{ type: 'boolean' },
{ type: 'command',
buttons:{
enable: ['update', 'insert', 'delete', 'submit', 'cancel'],
'update': { title:'Edit row' },
'insert': { title:'Add row' },
'delete': { title:'Delete row' },
'submit': { text:'Save', title:'Save' },
'cancel': { text:'Close', title:'Close' }
}
}
],
actions:{
'update': {
uri: 'php/employeeUpdate.php', submit_method: 'form', form_method: 'POST',
param_names: ['id','name','email','startdate','salary','active']
},
'insert': {
uri: 'php/employeeInsert.php', submit_method: 'form', form_method: 'POST',
param_names: ['id','name','email','startdate','salary','active'],
default_record: ['', 'Employee name...', 'employee@email.com', '2011-01-01','0', '']
},
'delete': {
uri: 'php/script.deleteEmployee.php', submit_method: 'script', bulk_delete: false,
param_names: ['id']
}
},
//Server activity callback events
on_server_activity_start: function(o, row){ setTimeout(function(){ o.Get('divLoader').style.display = 'block';}, 5); },
on_server_activity_stop: function(o, row){ setTimeout(function(){ o.Get('divLoader').style.display = 'none';}, 5); },
//Data validation delegate, the script does not provide data validation tools
validate_modified_value: function(o, colIndex, oldVal, newVal, cell, editor){
if(colIndex==2 && oldVal != newVal){
if(!et_ValidateEmail(newVal)){
alert('Please insert a valid email!');
return false;
} else return true;
}
else if(colIndex == 4 && oldVal != newVal){
if(isNaN(newVal)){
alert('Please insert a number!');
return false;
} else return true;
}
else return true;
},
open_custom_editor: function(o, cell, editor){
cell.appendChild(editor);
editor.style.display = '';
},
close_custom_editor: function(o, cell, editor){
editor.style.display = 'none';
document.body.appendChild(editor);
var d = o.Get('daySlc'), m = o.Get('monthSlc'), y = o.Get('yearSlc');
d.value = '';
m.value = '';
y.value = '';
},
get_custom_editor_value: function(o, editor, colIndex){
var strDate;
var d = o.Get('daySlc'), m = o.Get('monthSlc'), y = o.Get('yearSlc');
strDate = y.value+'-'+m.value+'-'+d.value;
return strDate;
},
set_custom_editor_value: function(o, editor, colIndex, val){
o.config.SetDateEditorValue(o, val, 'YMD');
},
//Custom toolip on row selection
on_after_selected_row: function(o, row){
if(!o.customTooltip || !demo2ActionsInfo || !row.getAttribute('id')) return;
var recordId = row.getAttribute('id').replace('tr','');
var actionInfo = demo2ActionsInfo[recordId]; //gets the associated actionInfo object
var div = o.Get('divActionInfo_'+recordId);
if(div){ div.style.display = 'block'; return; } //div already exists
if(actionInfo && actionInfo.hasOwnProperty('createDate')){
var locatorURL = 'http://www.infosniper.net/index.php?map_source=1&overview_map=1&lang=1&map_type=1&zoom_level=7&ip_address=';
div = o.CreateElm('div', ['id','divActionInfo_'+recordId]);
div.style.cssText = 'position:absolute; display:block; background:#FFFF99; border:1px solid #999; color:#000; padding:5px; margin:-70px 0 0 0px;';
div.innerHTML = 'Created on: '+actionInfo.createDate+ ' by: '+actionInfo.originIp+'' +
'Modified on: '+actionInfo.modDate+' by: '+(actionInfo.modIp!='' ? ''+actionInfo.modIp+'' : '')+'' +
'Deleted on: '+actionInfo.delDate+' by: '+(actionInfo.delIp!='' ? ''+actionInfo.delIp+'' : '')+'';
row.cells[0].appendChild(div);
}
},
on_before_deselected_row: function(o, row){
if(!demo2ActionsInfo || !row.getAttribute('id')) return;
var recordId = row.getAttribute('id').replace('tr','');
var div = o.Get('divActionInfo_'+recordId);
if(div){ div.parentNode.removeChild(div); div = null; }
},
//Messages
msg_submit_ok: 'Data processed successfully!',
msg_confirm_delete_selected_rows: 'Are you sure you want to delete the selected record?',
msg_error_occured: 'Error!' ,
msg_submit_unsuccessful: 'Data could not be saved correctly!',
//Custom date editor function, does not belong to ezEditTable script
SetDateEditorValue: function(o, val, dateType){
var date = tf_FormatDate(val, dateType);
var d = o.Get('daySlc'), m = o.Get('monthSlc'), y = o.Get('yearSlc');
var day = date.getDate(), month = date.getMonth()+1, year = date.getFullYear();
d.value = day.toString().length==1 ? '0'+day.toString() : day;
m.value = month.toString().length==1 ? '0'+month.toString() : month;
y.value = year;
}
};
Top of page