[英]EditorTable Pivot View in Laravel 4.2
I'm working on a Laravel App that happens to use the EditorTable (cousin to the DataTable from http://editor.datatables.net/ ). 我正在开发一个碰巧使用EditorTable的Laravel App(从http://editor.datatables.net/到DataTable的表兄弟)。 I can get the table to work fine with get and post but I have my SQL DB setup in w way where I need to make the editor dynamic.
我可以使表与get和post一起正常工作,但是我需要使用w方式设置SQL DB,从而需要使编辑器动态化。 Basically I have a table that has a course code and semester year as well as a metric response that the end users will plug in at the end of each year.
基本上,我有一个表,其中包含课程代码和学期,以及最终用户将在每年年底插入的指标响应。
How can I make the coding dynamic? 如何使编码动态化? Sometimes a course might have 5 metrics to show while another might have 15 in my DB.
有时一门课程可能显示5个指标,而另一门课程可能在我的数据库中包含15个指标。 (Instead of making my SQL table static I made it a simple collector because of the classes being different. I was thinking a for each loop but I could use some help here. Coding below:
(由于类的不同,我没有使我的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'
} );
} );
} );
This is where I'd like to make it dynamic if possible: 如果可能的话,这是我想使其动态的地方:
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 Headers: 表头:
<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>
My Ajax call: 我的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' )
Finally this is not a homework assignment I work for a College as a Database Admin and I'm touching into front end coding herewith php and laravel. 最后,这不是我在大学担任数据库管理员的家庭作业,我正在与PHP和laravel进行前端编码。
Ok so I figured out how I can go about making it dynamic, its not so much of a EditorTable as it is just making the data pivot. 好的,所以我想出了如何使它动态化的方法,它与其说是EditorTable无关,不如说只是使数据成为关键。 In Laravel 4.2 I was able to create a pivot in the blade and then make it editable.
在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() }}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.