在附加的 td 上获得 x-editable

我有一个表格,当用户从下拉列表中选择一个选项时,数据将返回其中,但附加的数据没有获得 x-editable 功能。


我想知道如何将 x-editable 添加到表中的附加数据中。


代码

view


$(document).ready(function() {


      $('.username').editable({

            url  : this.url,

            pk   : this.id,

            type : 'text',

            validate:function(value){

                if($.trim(value) === '')

                {

                    return 'This field is required';

                }

            }

        });

        

  $('select[name="school"]').on('change', function() {

    var schoolId = $(this).val();

    console.log(schoolId);


    $('.data_table').DataTable({

      "drawCallback": function(settings) {

        $('#ddd').html(settings._iRecordsTotal + ' Students');

      },


      processing: true,

      destroy: true,

      language: {

        processing: '<span>Processing...</span>',

      },

      serverSide: true,

      ajax: '{{ url('

      dashboard / studentsIndexData ') }}/' + schoolId,

      columns: [{

          data: 'id'

        },

        {

          data: 'photo'

        },

        {

          data: 'students'

        },

        {

          data: 'semester'

        },

        {

          data: 'class'

        },

        {

          data: 'action',

          orderable: false,

          searchable: false

        },

      ],

      "order": [

        [0, "desc"]

      ],

      dom: 'Bfrtip',

      buttons: [{

          extend: 'copy',

          exportOptions: {

            columns: [0, ':visible']

          }

        },

        {

          extend: 'excel',

          exportOptions: {

            columns: ':visible'

          }

        },

        {

          extend: 'csv',

          exportOptions: {

            columns: ':visible'

          }

        },

        {

          extend: 'pdfHtml5',

          exportOptions: {

            columns: [2, 3, 1]

          }

        },

        {

          extend: 'print',

          exportOptions: {

            columns: ':visible'

          }

        },

        'colvis'

      ]

    });

  });

});


拉风的咖菲猫
浏览 83回答 1
1回答

holdtom

解决了我将我的editable功能移动到dataTables drawCallback现在它正在工作"drawCallback": function( settings ) {&nbsp; &nbsp;$('#ddd').html(settings._iRecordsTotal + ' Students');&nbsp; &nbsp;$('.username').editable({&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url&nbsp; : this.url,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pk&nbsp; &nbsp;: this.id,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type : 'text',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; validate:function(value){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if($.trim(value) === '')&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 'This field is required';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; });},它能做什么?基本上它拥有可编辑的功能,直到 dataTables 将数据返回到表中。希望对有需要的人有所帮助。
打开App,查看更多内容
随时随地看视频慕课网APP