From 0ee56daa307d202aa5241ef478066be3535397df Mon Sep 17 00:00:00 2001 From: Peter van der Leek Date: Sat, 1 Oct 2016 10:42:33 +0200 Subject: [PATCH 1/5] Added options for confirmButton, cancelButton and buttonText (datepicker) Several code styling improvements --- README.md | 67 +++++++++-------- example/advanced.html | 2 - example/advanced.js | 65 +++++++++-------- example/basic.html | 1 - example/basic.js | 12 +-- js/dataTables.cellEdit.js | 149 ++++++++++++++++++++++---------------- 6 files changed, 160 insertions(+), 136 deletions(-) diff --git a/README.md b/README.md index 294cedb..bb582b1 100644 --- a/README.md +++ b/README.md @@ -21,56 +21,59 @@ Property | Type | Default | Example | Details ```javascript var table = $('#myTable').DataTable(); - function myCallbackFunction (updatedCell, updatedRow, oldValue) { - console.log("The new value for the cell is: " + updatedCell.data()); - console.log("The values for each cell in that row are: " + updatedRow.data()); + function myCallbackFunction (updatedCell, updatedRow, oldValue, newValue) { + console.log('The new value for the cell is: ' + newValue); + console.log('The values for each cell in that row are: ' + updatedRow.data()); } table.MakeCellsEditable({ - "onUpdate": myCallbackFunction + 'onUpdate': myCallbackFunction }); ``` ### Advanced Initialization ```javascript var table = $('#myAdvancedTable').DataTable(); - function myCallbackFunction(updatedCell, updatedRow, oldValue) { - console.log("The new value for the cell is: " + updatedCell.data()); - console.log("The values for each cell in that row are: " + updatedRow.data()); + function myCallbackFunction(updatedCell, updatedRow, oldValue, newValue) { + console.log('The new value for the cell is: ' + newValue); + console.log('The values for each cell in that row are: ' + updatedRow.data()); } table.MakeCellsEditable({ - "onUpdate": myCallbackFunction, - "inputCss":'my-input-class', - "columns": [0,1,2], - "allowNulls": { - "columns": [1], - "errorClass": 'error' + 'onUpdate': myCallbackFunction, + 'inputCss': 'my-input-class', + 'columns': [0,1,2], + 'allowNulls': { + 'columns': [1], + 'errorClass': 'error' }, - "confirmationButton": { - "confirmCss": 'my-confirm-class', - "cancelCss": 'my-cancel-class' + 'confirmationButton': { + 'confirmButton': 'Save changes', + 'confirmCss': 'my-confirm-class', + 'cancelButton': 'No thanks', + 'cancelCss': 'my-cancel-class' }, - "inputTypes": [ + 'inputTypes': [ { - "column":0, - "type":"text", - "options":null + 'column':0, + 'type': 'text', + 'options': null }, { - "column":1, - "type": "list", - "options":[ - { "value": "1", "display": "Beaty" }, - { "value": "2", "display": "Doe" }, - { "value": "3", "display": "Dirt" } + 'column': 1, + 'type': 'list', + 'options': [ + { 'value': '1', 'display': 'Beaty' }, + { 'value': '2', 'display': 'Doe' }, + { 'value': '3', 'display': 'Dirt' } ] - } - ,{ - "column": 2, - "type": "datepicker", // requires jQuery UI: http://http://jqueryui.com/download/ - "options": { - "icon": "http://jqueryui.com/resources/demos/datepicker/images/calendar.gif" // Optional + }, + { + 'column': 2, + 'type': 'datepicker', // requires jQuery UI: http://http://jqueryui.com/download/ + 'options': { + 'icon': 'http://jqueryui.com/resources/demos/datepicker/images/calendar.gif', // Optional + 'buttonText': 'Select a date' // Optional } } ] diff --git a/example/advanced.html b/example/advanced.html index e13cab1..05ccfe2 100644 --- a/example/advanced.html +++ b/example/advanced.html @@ -1,7 +1,6 @@  -