EditorTable Pivot View in Laravel 4.2


EditorTable Pivot View in Laravel 4.2

我正在开发一个Laravel应用程序,该应用程序恰好使用EditorTable(http://editor.datatables.net/)。我可以使用get和post使表正常工作,但我的SQL DB设置方式需要使编辑器动态。基本上,我有一个表格,里面有课程代码和学年,以及最终用户将在每年年底插入的指标响应。

如何使编码动态?有时一门课程可能有5个指标要显示,而另一门课程的DB中可能有15个。(由于类不同,我没有将SQL表设置为静态的,而是将其设置为一个简单的收集器。我想为每个循环创建一个,但我可以在这里使用一些帮助。编码如下:

var table = $('#example').DataTable( {
                                        // Makes one continuous line - jsg 2/12/2016
            "scrollX": true,
            "autoWidth": false,
                                        // How many rows to return - jsg 2/16/2016
                "pageLength": 25,
                                        // Setup the search box with the current username to filter the values on the screen - jsg 2/12/2016
                "search": {search: '<?php echo $auth_id;?>' + ' INQ 300 '   },
                                        // End Search Setup populate
                dom: "Bfrtip",
               ajax: "../app/controllers/INQControllers.php"
                columns: [
                    {
                        data: null,
                        defaultContent: '',
                        className: 'select-checkbox',
                        orderable: false
                    },
                    { data: "fkey_instructor1_rcid", visible: false },
                    { data: "first_name" },
                    { data: "last_name" },
                    { data: "fkey_course_id" },
                    { data: "course_code"  },
                    { data: "course_number" },
                    { data: "course_section" },
              { data: "fkey_semester_id"},
              { data: "category"},
              { data: "Metric_text"},
              { data: "response_value"}
                ],
                order: [ 1, 'asc' ],
                keys: {
                    columns: ':not(:first-child)',
                    keys: [ 9 ]
                },
                select: {
                    style:    'os',
                    selector: 'td:first-child'
                },
                buttons: [
                    { extend: "edit",   editor: editor },
              {
                  extend: 'collection',
                  text: 'Export',
                  buttons: [
                      'copy',
                      'excel',
                      'csv',
                      'pdf',
                      'print'
                  ]
              }
                    //{ extend: "remove", editor: editor }
                ]
            } );
               // Activate an inline edit on click of a table cell
            $('#example').on( 'click', 'tbody td:not(:first-child)', function (e) {
                editor.inline( this );
            } );
            // Inline editing on tab focus
             table.on( 'key-focus', function ( e, datatable, cell ) {
                 editor.inline( cell.index(), {
                     onBlur: 'submit'
                 } );
                          } );

            } );

如果可能的话,这就是我想让它变得动态的地方:

columns: [
                        {
                            data: null,
                            defaultContent: '',
                            className: 'select-checkbox',
                            orderable: false
                        },
                        { data: "fkey_instructor1_rcid", visible: false },
                        { data: "first_name" },
                        { data: "last_name" },
                        { data: "fkey_course_id" },
                        { data: "course_code"  },
                        { data: "course_number" },
                        { data: "course_section" },
                  { data: "fkey_semester_id"},
                  { data: "category"},
                  { data: "Metric_text"},
                  { data: "response_value"}

表格标题:

<table id="example" class="display" cellspacing="0" width="100%">
                                <thead>
                                    <tr>
                                        <th></th>
                            <th>Instructor</th>
                                    <th>First Name</th>
                                        <th>Last Name</th>
                                          <th>Course ID</th>
                                <th>Code</th>
                                <th>Number</th>
                                <th>Section</th>
                              <th>Sesmenter</th>
                              <th>Category</th>
                              <th>Metric Text</th>
                              <th width="3%">Metric Value</th>
                                    </tr>
                        </table>
                                </thead>

我的Ajax调用:

Editor::inst( $db, 'gen_ed_assessment.responses_data_record')
    ->fields(
        Field::inst( 'fkey_instructor1_rcid' )->validator( 'Validate::notEmpty' ),
        Field::inst( 'category' )->validator( 'Validate::notEmpty' ),
        Field::inst( 'Metric_text' ),
        Field::inst( 'response_value' )
                 ->validator( 'Validate::values',  array('valid' => array("0.0","0.5","1.0","1.5", "2.0", "2.5","3.0", "3.5", "4.0"))),
        Field::inst( 'fkey_course_id' ),
        Field::inst( 'id' ),
        Field::inst( 'first_name' ),
        Field::inst( 'last_name' ),
        Field::inst( 'fkey_semester_id' ),
        Field::inst( 'course_code' ),
        Field::inst( 'course_number' ),
        Field::inst( 'course_section' )

最后,这不是我在一所大学担任数据库管理员的家庭作业,我正在接触php和laravel的前端编码。

好吧,所以我想好了如何使它成为动态的,与其说它是一个EditorTable,不如说它只是一个数据透视。在Laravel 4.2中,我能够在刀片中创建一个枢轴,然后使其可编辑。

{{ HTML::row() }}
  {{ HTML::col(12, 12, 12, 12) }}
  <h3>{{ $section->Description}}</h3>
  <h4>{{ $section->fkey_CourseCodeId }}- {{ $section->Number }}- {{ $section->ClassSection }}</h4>
  <th>Number</th>
  <th>Section</th>
  <th>Semester</th>
    {{ HTML::table(array('class' => 'table table-striped table-bordered table-hover table-condensed datatable')) }}
      <thead>
        <tr>
          <th>First Name</th>
          <th>Last Name</th>
          @foreach($rubrics as $rubric)
            @foreach($rubric->metric_category->metrics as $metric)
              <th>{{ $metric->metric_text }}</th>
            @endforeach
          @endforeach
        </tr>
      </thead>
      <tbody>
        @foreach($registrations as $registration)
          <tr>
            <td></td>
            <td>{{$registration->RCID}}</td>
          </tr>
        @endforeach
      </tbody>
    {{ HTML::closeTable() }}
  {{ HTML::closeCol() }}
{{ HTML::closeRow() }}