Field hide in DataTable and make it to save in database

Field hide in DataTable and make it to save in database

elenasteninaelenastenina Posts: 5Questions: 2Answers: 0

Hello,
Can you please help to figure out how to able to hide field( using "type":"hidden") and save it in database?
I am using a long id number for each row to able to implement it later from database but user should't be see this id number then click on button "New" to create a new row.
My code:
(function($){

$(document).ready(function() {
var editor = new $.fn.dataTable.Editor( {
ajax: '/api/AdjustmentTable',
table: '#AdjustmentTable',
fields: [
{
"label": "FormInstanseID:",
"name": "forminstanseid",
//"type":"hidden"

        },
        {
            "label": "MAT#:",
            "name": "mat"
        },
        {
            "label": "Description:",
            "name": "description",
            "type": "textarea"
        },
        {
            "label": "Plus or Minus QTY:",
            "name": "plus_or_minus_qty"
        },
        {
            "label": "Unit Cost:",
            "name": "unit_cost"
        },
        {
            "label": "Extended Cost:",
            "name": "extended_cost"
        }
    ]
} );

var table = $('#AdjustmentTable').DataTable( {
    dom: 'Bfrtip',
    ajax: '/api/AdjustmentTable',
    columns: [
        {
            "data": "forminstanseid"
        },
        {
            "data": "mat"
        },
        {
            "data": "description"
        },
        {
            "data": "plus_or_minus_qty"
        },
        {
            "data": "unit_cost"
        },
        {
            "data": "extended_cost"
        }
    ],
    select: true,
    lengthChange: false,
    buttons: [
        { extend: 'create', editor: editor },
        { extend: 'edit',   editor: editor },
        { extend: 'remove', editor: editor }
    ]
});

} );

}(jQuery));

in html:

FormInstanseID MAT# Description Plus or Minus QTY Unit Cost Extended Cost

FormInstanseId column should be hidden but it go with long id automatically when you click a button "New" to create a new row.

When I use type":"hidden" in field of editor, it hide a field but it is not save the data in database.
fields: [
{
"label": "FormInstanseID:",
"name": "forminstanseid",
//"type":"hidden"

        },

How to resolve it and what do I need to use?
Thank you very much!

Sign In or Register to comment.