Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

datatables modify rows

const table = $("#tableId").DataTable();

table.rows().every( function() {
	const node = this.node(); // html node -- tr
  	const row = $(node).find('td:eq(2)'); // 3rd (0-index) column -- td
}
Comment

edit data in datatable

Javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
var editor; // use a global for the submit and return data rendering in the examples
 
$(document).ready(function() {
    editor = new $.fn.dataTable.Editor( {
        ajax: "../php/staff.php",
        table: "#example",
        fields: [ {
                label: "First name:",
                name: "first_name"
            }, {
                label: "Last name:",
                name: "last_name"
            }, {
                label: "Position:",
                name: "position"
            }, {
                label: "Office:",
                name: "office"
            }, {
                label: "Extension:",
                name: "extn"
            }, {
                label: "Start date:",
                name: "start_date",
                type: "datetime"
            }, {
                label: "Salary:",
                name: "salary"
            }
        ]
    } );
 
    // Activate an inline edit on click of a table cell
    $('#example').on( 'click', 'tbody td:not(:first-child)', function (e) {
        editor.inline( this );
    } );
 
    $('#example').DataTable( {
        dom: "Bfrtip",
        ajax: "../php/staff.php",
        order: [[ 1, 'asc' ]],
        columns: [
            {
                data: null,
                defaultContent: '',
                className: 'select-checkbox',
                orderable: false
            },
            { data: "first_name" },
            { data: "last_name" },
            { data: "position" },
            { data: "office" },
            { data: "start_date" },
            { data: "salary", render: $.fn.dataTable.render.number( ',', '.', 0, '$' ) }
        ],
        select: {
            style:    'os',
            selector: 'td:first-child'
        },
        buttons: [
            { extend: "create", editor: editor },
            { extend: "edit",   editor: editor },
            { extend: "remove", editor: editor }
        ]
    } );
} );
Comment

PREVIOUS NEXT
Code Example
Javascript :: foeach in js 
Javascript :: how to get value in array object value using for loop in javascript 
Javascript :: javascript template string 
Javascript :: javascript array from string 
Javascript :: redux reducer 
Javascript :: expressjs req.body.parameters 
Javascript :: or operator js 
Javascript :: js get img under div 
Javascript :: react icon import 
Javascript :: dynamic set required in angular using formcontrol 
Javascript :: Find out the sum, minimum and maximum value in javascript 
Javascript :: cra proxy 
Javascript :: angular get class list for element 
Javascript :: how to get the last two characters of a string in javascript 
Javascript :: createelement with id 
Javascript :: get the location of an item in an array 
Javascript :: javascript check if undefined or null or empty string 
Javascript :: create audio tag javascript 
Javascript :: Vuejs + Laravel router redirection issue 
Javascript :: javascript how to pass more than one selector in querySelectorall 
Javascript :: on button click show collapse div jquery 
Javascript :: js get datatable attr value on click 
Javascript :: new date getday js 
Javascript :: disable zoom in app 
Javascript :: Javascript object convert into JSON 
Javascript :: node cron schedule specific time 
Javascript :: React native calender date picker 
Javascript :: New JSDOM and querySelector elems textContent 
Javascript :: sanitize html in javascript 
Javascript :: function for flatten an array 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =