私はLaravel Appで、EditorTable(DataTableの従兄弟)をhttp://editor.datatables.net/から使用しています。私は取得し、ポストでうまく動作するようにテーブルを得ることができますが、エディタを動的にするために必要なところで私のSQL DBのセットアップがあります。基本的に私は、コースコードと学年があるテーブルと、エンドユーザーが毎年末に接続するメトリックレスポンスを持っています。EditorTableピボットビューin Laravel 4.2
どのようにコーディングを動的にすることができますか?コースには5つの指標が表示され、別の指標には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'
});
});
});
これは、 「可能な場合は、それを動的にしたいとdは:
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でフロントエンドコーディングに触れています。