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 | |
---|---|---|---|---|---|---|
53216 | hjkhkHUhu | employee@email.com | 2011-01-01 | 0.00 | ||
53215 | ccvcvcv | employee@email.com | 2011-01-01 | 0.00 | ||
53214 | Employee name... | 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 | ||
53166 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53165 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53164 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53163 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53162 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53161 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53160 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53159 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53158 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53157 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53156 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53155 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53154 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53153 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53152 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53151 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53150 | Employee name... | employee@email.com | 0000-00-00 | 0.00 | ||
53149 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53148 | Ca ro | employee@email.com | 2011-01-16 | 0.00 | ||
53147 | Employee name... | employee@email.com | 2011-05-16 | 1000.00 | ||
53146 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53145 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53144 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53143 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53142 | Employee name... | employee@gmail.com | 2011-01-01 | 0.00 | ||
53141 | employee@email.com | 2011-01-01 | 0.00 | |||
53140 | polanka | employee@email.com | 2011-01-01 | 0.00 | ||
53139 | Kozio?ek | employee@email.com | 2011-01-01 | 0.00 | ||
53138 | Anka | employee@email.com | 2019-01-24 | 0.28 | ||
53137 | Marek | employee1@email.com | 2011-01-01 | 12.25 | ||
53136 | Bolek | employee@email.com | 2011-01-01 | 0.00 | ||
53135 | Matolek | employee@email.com | 2011-01-01 | 236.00 | ||
53134 | Nome del lllllll... | dipendente@email.com | 2011-01-01 | 0.00 | ||
53133 | Employee name... | employee@email.com | 2011-01-01 | 1258.02 | ||
53132 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53131 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53130 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53129 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53128 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53127 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53126 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53125 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53124 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53123 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53122 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53121 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53120 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53119 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53118 | Employee name... | employee@email.com | 2011-01-01 | 0.00 | ||
53117 | 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