Professional Documents
Culture Documents
Support ItisworthnotingthatButtonsisusedin
thisexampleforsimplicity,butyoucould
Download useanycontrolonyourpagethatyou
wish!
Purchase
Start
Name Position Office Extn. Salary
date
2008
AiriSatou Accountant Tokyo 5407 $162,700
1128
Chief
Angelica 2009
Executive London 5797 $1,200,000
Ramos 1009
Officer(CEO)
Junior
San 2009
AshtonCox Technical 1562 $86,000
Francisco 0112
Author
Software 2011
BrunoNash London 6222 $163,500
Engineer 0503
https://editor.datatables.net/examples/api/triggerButton.html 1/5
12.03.2017. DataTables example - Customised control buttons
Start
Name Position Office Extn. Salary
date
Senior
2012
CedricKelly Javascript Edinburgh 6224 $433,060
0329
Developer
Start
Name Position Office Extn. Salary
date
Showing1to10of57entries
Previous 1 2 3 4 5 6 Next
1 Javascript
vareditor//useaglobalforthesubmitandreturndatarenderi
2
3 $(document).ready(function(){
4 editor=new$.fn.dataTable.Editor({
5 ajax:"../php/staff.php",
6 table:"#example",
7 fields:[{
8 label:"Firstname:",
9 name:"first_name"
10 },{
11 label:"Lastname:",
12 name:"last_name"
13 },{
14 label:"Position:",
15 name:"position"
16 },{
17 label:"Office:",
18 name:"office"
Youraccount:
DataTables Editor
19 },{
Login/Register
Search...
20 label:"Extension:",
21 name:"extn"
22 },{
23 label:"Startdate:",
24 name:"start_date"
25 },{
26 label:"Salary:",
27 name:"salary"
28 }
https://editor.datatables.net/examples/api/triggerButton.html 2/5
12.03.2017. DataTables example - Customised control buttons
29 ]
30 })
31
32 vartable=$('#example').DataTable({
33 dom:"Bfrtip",
34 ajax:"../php/staff.php",
35 columns:[
36 {data:null,render:function(data,type,row){
37 //Combinethefirstandlastnamesintoasingle
38 returndata.first_name+''+data.last_name
39 }},
40 {data:"position"},
41 {data:"office"},
42 {data:"extn"},
43 {data:"start_date"},
44 {data:"salary",render:$.fn.dataTable.render.number
45 ],
46 select:true,
47 buttons:[
48 {extend:"create",editor:editor},
49 {extend:"edit",editor:editor},
50 {
51 extend:"selectedSingle",
52 text:"Salary+250",
53 action:function(e,dt,node,config){
54 //Immediatelyadd`250`tothevalueofthes
55 editor
56 .edit(table.row({selected:true
57 .set('salary',(editor.get('salary'
58 .submit()
59 }
60 },
61 {extend:"remove",editor:editor}
62 ]
63 })
64 })
Inadditiontotheabovecode,thefollowingJavascriptlibraryfilesareloaded
foruseinthisexample:
//code.jquery.com/jquery1.12.4.js
https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js
https://cdn.datatables.net/buttons/1.2.4/js/dataTables.buttons.min.js
https://cdn.datatables.net/select/1.2.1/js/dataTables.select.min.js
../../extensions/Editor/js/dataTables.editor.min.js
Youraccount:
DataTables Editor Login/Register
Search...
Otherexamples
https://editor.datatables.net/examples/api/triggerButton.html 3/5
12.03.2017. DataTables example - Customised control buttons
Simpleinitialisation Datesandtime
Basicinitialisation Datepicker
Multirowediting Formatteddates
Fieldtypes Dateandtimeinput
Settingdefaults Timeinputs
Localtableediting Timeincrementoptions
Internationalisation Optionsminandmaxdates
Intableformcontrols Optionsweeknumbers
Serversideprocessing Optionsdisabledays
Customformlayout/templates Internationalisation
Jointablesworkingwithmultiple jQueryUIDatePicker
SQLtables jQueryUIDatePickerwithcustom
formatting
Advancedinitialisation HTML5dateinput
Datashownonlyintheform
Datashownintableonly Inlineediting
Multiitemediting(rows,columns, Simpleinlineediting
cells) Tabbetweencolumns
RESTinterface Editingoptionssubmitonblur
Complex(nested)JSONdata Editingoptionssubmitfullrowdata
source
Inlineeditingwithasubmitbutton
AjaxoverrideusinglocalStorage
forthedatasource Editicon
RowIDsourcespecification Joinedtables
Compounddatabaseprimarykey Responsiveintegration
DOMsourcedtable Selectedcolumnsonly
Jointablesselfreferencingjoin FixedColumnsintegration
Jointableslinktable
Bubbleediting
Jointablesonetomanyjoin
Simplebubbleediting
Fileupload
Multiplefieldsinabubble
Fileupload(many)
Formcontrolanddisplayoptions
DataTablesextensions
Youraccount:
Defaultcontrolanddisplayoptions
DataTables Editor Login/Register
Search...
Bubbleeditingwithintablerow
Excellikekeyboardnavigation
controls
ExcellikeAutoFillfeature
AutoFillandKeyTabletogether
Exportbuttons
Responsivetableextension
Rowreordering
https://editor.datatables.net/examples/api/triggerButton.html 4/5
12.03.2017. DataTables example - Customised control buttons
API Styling
Dependentfields Bootstrap3
Eventsunsavedchangesclose Bootstrap4
confirmation Foundation
Clientsidevalidation SemanticUI
Customisedcontrolbuttons jQueryUI
Previous/nexteditingbuttons Fielddisplaystylingoptions
Cancelbutton Multicolumnlayout
Alwaysshowncheckbox Largewindowlayout
Duplicatebutton Stackedinputs
Customdelete/removemessage Envelopedisplaycontroller
Envelopedisplaywithintable
Standalone controls
Simplestandaloneediting Customformlayout/templates
Bubbleediting
Inlineediting Plugins
Standalonecollectioneditor Customfieldtypeplugins
Customdisplaycontroller
DataTablesandEditordesignedandcreatedbySpryMediaLtd20122016
SpryMediaLtdisregisteredinScotland,companyno.SC456502.
Youraccount:
DataTables Editor Login/Register
Search...
https://editor.datatables.net/examples/api/triggerButton.html 5/5