如何在数据表中获取更改的输入值?

时间:2019-11-15 07:42:05

标签: javascript datatable datatables

我正在使用类似于数据表的内联编辑功能 https://legacy.datatables.net/release-datatables/examples/api/editable.html

我要应用验证。以下是我的数据表代码:

<script type="text/javascript" charset="utf-8">
    var oTable;
    $(function() {
        oTable = $('#id_datatable_tablas_admin').dataTable({
            "sAjaxSource": "ajax/admin_get_tabla.php?tabla=config_aplicacion&addColumn=Delete",
            "iDisplayLength": 20,
            "aLengthMenu": [[20, 100,-1], [20, 100, "All"]],
            "fnCreatedRow": function( nRow, aData, iDataIndex ) { /*Fila creada*/ } ,
            "fnDrawCallback": function( oSettings ) { /*Tabla Modificada*/ 
                anadir_funcionalidad_datatable_tablas_admin();
            },
            "bProcessing": true,
            "bServerSide": true,
            "sScrollY": 524,
            "aoColumnDefs": [
                 { "aTargets": [0],"sClass": "" },
                 { "aTargets": [1],"sClass": "td_editable" },
                 { "aTargets": [2],"sClass": "td_editable" },
                 { "aTargets": [3],"sClass": "td_eliminar" }
            ],
            "sPaginationType": "full_numbers", "sDom": 'R<"H"lfr>t<"F"ip>',
            "oLanguage": { "sUrl": "ajax/datatable-en.txt" }
        });
        $("#id_datatable_tablas_admin tfoot input").keyup( function (){
            oTable.fnFilter( this.value, $("tfoot input").index(this));
        });
    });

    function anadir_funcionalidad_datatable_tablas_admin(){
        /* Apply the jEditable handlers to the table */      
        oTable.$('td.td_editable').editable( 'ajax/admin_edita_tabla.php?tabla=config_aplicacion', {
            "callback": function( sValue, y ) {
                var aPos = oTable.fnGetPosition( this );
                oTable.fnUpdate( sValue, aPos[0], aPos[1] );
            },
            "submitdata": function ( value, settings ) {
                return {
                    "id": $(this).parent().find('td:eq(0)').html(),
                    "columna": oTable.fnGetPosition( this )[2]
                };
            },
            "height": "14px",
            "width": "100%"
        });
    }
</script>

我想,我需要将验证放入Submitdata中。但是,我不确定。 如何验证?

或者至少我可以在Submitdata中获得输入值的更改,然后我也可以进行验证。

请帮助。

0 个答案:

没有答案