javascript - Working with FooTable Data -
i'm using footable editing table adding new row through insert new row. data being added table want data should insert in input field can send data database.
here in snippet of work data adding in row
var $modal = $('#editor-modal'), $editor = $('#editor'), $editortitle = $('#editor-title'), ft = footable.init('#footable_2', { editing: { enabled: true, addrow: function(){ $modal.removedata('row'); $editor[0].reset(); $editortitle.text('add new row'); $modal.modal('show'); }, editrow: function(row){ var values = row.val(); $editor.find('#id').val(values.id); $editor.find('#firstname').val(values.firstname); $editor.find('#lastname').val(values.lastname); $editor.find('#jobtitle').val(values.jobtitle); $editor.find('#startedon').val(values.startedon); $editor.find('#dob').val(values.dob); $editor.find('#sgst').val(values.sgst); $editor.find('#cgst').val(values.cgst); $editor.find('#igst').val(values.igst); $modal.data('row', row); $editortitle.text('edit row #' + values.id); $modal.modal('show'); }, deleterow: function(row){ if (confirm('are sure want delete row?')){ row.delete(); } } } }), uid = 2; $editor.on('submit', function(e){ if (this.checkvalidity && !this.checkvalidity()) return; e.preventdefault(); var row = $modal.data('row'), values = { id: $editor.find('#id').val(), firstname: $editor.find('#firstname').val(), lastname: $editor.find('#lastname').val(), jobtitle: $editor.find('#jobtitle').val(), startedon:$editor.find('#startedon').val(), dob:$editor.find('#dob').val(), sgst:$editor.find('#sgst').val(), cgst:$editor.find('#cgst').val(), igst:$editor.find('#igst').val() }; if (row instanceof footable.row){ row.val(values); } else { values.id = uid++; ft.rows.add(values); } $modal.modal('hide'); }); }); <table id="footable_2" class="table" data-paging="true" > <thead> <tr> <th data-name="id" data-breakpoints="xs" data-type="number">id</th> <th data-name="firstname">material code</th> <th data-name="lastname">material name</th> <th data-name="jobtitle">hsn code</th> <th data-name="startedon">p&f</th> <th data-name="dob" >freight</th> <th data-name="sgst" >sgst%</th> <th data-name="cgst" >cgst%</th> <th data-name="igst" >igst%</th> </tr> </thead> <tbody> </tbody> </table> the code snippet me achieve goal.
Comments
Post a Comment