Я пытаюсь получить желаемый порядок для столбцов с данными.
Я пробовал эти два решения, которые я получил через документы с датированными данными.
https://datatables.net/extensions/rowreorder/examples/initialisation/restrictedOrdering.html
https://datatables.net/reference/option/columnDefs.targets
Но никто из них не работал для меня.
Это просто обзор таблицы, как она выглядит: https://app.hyfy.io/v/abz9KaAAzan/
Проверьте этот скриншот: https://prnt.sc/n92d03 (Это проблема, с которой я сталкиваюсь сейчас)
Таким образом, каждая нераспределенная категория td идет сразу после первой категории (относится к третьему столбцу) в каждом активе (относится ко второму столбцу) и к этому нераспределенному столбцу, который я добавляю во внешний интерфейс, используя условие if.
Теперь я получаю правильный порядок для второго столбца (сделал этот порядок при запросе бэкэнда), как хочет клиент, но нераспределенный идет не туда.
Если я добавлю порядок для третьего столбца для этой таблицы данных, порядок второго столбца изменится.
Datatable jquery:
// "ordering": false,
"scrollY": "650px",
"paging": false,
'rowsGroup': [0, 1],
scrollX: true,
fixedColumns: {
leftColumns: 3
},
"order": [
[2, "asc"]
],
"aoColumnDefs": [{
'bSortable': false,
'aTargets': ['nosort']
}]
});
Массив результатов:
Array
(
[0] => Array
(
[id] => 25
[asset_id] => 4
[description] => PL31
[created_at] => 2017-08-17 13:40:48
[updated_at] => 2017-08-17 13:40:48
[status] => 1
[cost_code] => P0030
[weight] => 0.00
[deleted_at] =>
[active_from] => 0000-00-00
[inactive_from] => 0000-00-00
[asset] => Array
(
[id] => 4
[name] => 0.35m Planer
[default_rate] =>
[tax_id] => 1
[nominal_code] => 00002
[created_at] => 2017-07-24 20:41:26
[updated_at] => 2018-06-12 17:26:52
[status] => 1
[weekday_am] => 165
[weekday_pm] => 165
[weekend_am] => 165
[weekend_pm] => 165
[group_id] => 3
[cost_weekday_am] => 132
[cost_weekend_am] => 132
[cost_weekend_pm] => 132
[cost_weekday_pm] => 132
[project_code] =>
[manufacturer] =>
[model] =>
[purchase_date] => 0000-00-00
[warranty_expiry] =>
[mot_due] =>
[group] => Array
(
[id] => 3
[name] => Planers
[status] => 1
[created_at] => 2017-07-14 17:21:49
[updated_at] => 2017-07-14 17:21:49
)
)
[asset_id_allocations] => Array
(
)
)
[1] => Array
(
[id] => 26
[asset_id] => 4
[description] => PL32
[created_at] => 2017-08-17 13:40:51
[updated_at] => 2017-08-17 13:40:51
[status] => 1
[cost_code] => P0031
[weight] => 0.00
[deleted_at] =>
[active_from] => 0000-00-00
[inactive_from] => 0000-00-00
[asset] => Array
(
[id] => 4
[name] => 0.35m Planer
[default_rate] =>
[tax_id] => 1
[nominal_code] => 00002
[created_at] => 2017-07-24 20:41:26
[updated_at] => 2018-06-12 17:26:52
[status] => 1
[weekday_am] => 165
[weekday_pm] => 165
[weekend_am] => 165
[weekend_pm] => 165
[group_id] => 3
[cost_weekday_am] => 132
[cost_weekend_am] => 132
[cost_weekend_pm] => 132
[cost_weekday_pm] => 132
[project_code] =>
[manufacturer] =>
[model] =>
[purchase_date] => 0000-00-00
[warranty_expiry] =>
[mot_due] =>
[group] => Array
(
[id] => 3
[name] => Planers
[status] => 1
[created_at] => 2017-07-14 17:21:49
[updated_at] => 2017-07-14 17:21:49
)
)
[asset_id_allocations] => Array
(
)
)
[2] => Array
(
[id] => 156
[asset_id] => 4
[description] => PL33
[created_at] => 2017-11-14 14:56:52
[updated_at] => 2017-11-14 14:56:52
[status] => 1
[cost_code] => P0032
[weight] => 0.00
[deleted_at] =>
[active_from] => 0000-00-00
[inactive_from] => 0000-00-00
[asset] => Array
(
[id] => 4
[name] => 0.35m Planer
[default_rate] =>
[tax_id] => 1
[nominal_code] => 00002
[created_at] => 2017-07-24 20:41:26
[updated_at] => 2018-06-12 17:26:52
[status] => 1
[weekday_am] => 165
[weekday_pm] => 165
[weekend_am] => 165
[weekend_pm] => 165
[group_id] => 3
[cost_weekday_am] => 132
[cost_weekend_am] => 132
[cost_weekend_pm] => 132
[cost_weekday_pm] => 132
[project_code] =>
[manufacturer] =>
[model] =>
[purchase_date] => 0000-00-00
[warranty_expiry] =>
[mot_due] =>
[group] => Array
(
[id] => 3
[name] => Planers
[status] => 1
[created_at] => 2017-07-14 17:21:49
[updated_at] => 2017-07-14 17:21:49
)
)
[asset_id_allocations] => Array
(
)
)
[3] => Array
(
[id] => 27
[asset_id] => 5
[description] => PL51
[created_at] => 2017-08-17 13:41:19
[updated_at] => 2017-08-17 13:41:19
[status] => 1
[cost_code] => P0033
[weight] => 0.00
[deleted_at] =>
[active_from] => 0000-00-00
[inactive_from] => 0000-00-00
[asset] => Array
(
[id] => 5
[name] => 0.5m Planer
[default_rate] =>
[tax_id] => 1
[nominal_code] => 00002
[created_at] => 2017-07-24 20:41:45
[updated_at] => 2018-06-12 17:26:23
[status] => 1
[weekday_am] => 190
[weekday_pm] => 190
[weekend_am] => 190
[weekend_pm] => 190
[group_id] => 3
[cost_weekday_am] => 152
[cost_weekend_am] => 152
[cost_weekend_pm] => 152
[cost_weekday_pm] => 152
[project_code] =>
[manufacturer] =>
[model] =>
[purchase_date] => 0000-00-00
[warranty_expiry] =>
[mot_due] =>
[group] => Array
(
[id] => 3
[name] => Planers
[status] => 1
[created_at] => 2017-07-14 17:21:49
[updated_at] => 2017-07-14 17:21:49
)
)
[asset_id_allocations] => Array
(
)
)
[4] => Array
(
[id] => 28
[asset_id] => 5
[description] => PL53
[created_at] => 2017-08-17 13:41:22
[updated_at] => 2017-08-17 13:41:22
[status] => 1
[cost_code] => P0034
[weight] => 0.00
[deleted_at] =>
[active_from] => 0000-00-00
[inactive_from] => 0000-00-00
[asset] => Array
(
[id] => 5
[name] => 0.5m Planer
[default_rate] =>
[tax_id] => 1
[nominal_code] => 00002
[created_at] => 2017-07-24 20:41:45
[updated_at] => 2018-06-12 17:26:23
[status] => 1
[weekday_am] => 190
[weekday_pm] => 190
[weekend_am] => 190
[weekend_pm] => 190
[group_id] => 3
[cost_weekday_am] => 152
[cost_weekend_am] => 152
[cost_weekend_pm] => 152
[cost_weekday_pm] => 152
[project_code] =>
[manufacturer] =>
[model] =>
[purchase_date] => 0000-00-00
[warranty_expiry] =>
[mot_due] =>
[group] => Array
(
[id] => 3
[name] => Planers
[status] => 1
[created_at] => 2017-07-14 17:21:49
[updated_at] => 2017-07-14 17:21:49
)
)
[asset_id_allocations] => Array
(
)
)
[5] => Array
(
[id] => 29
[asset_id] => 5
[description] => PL54
[created_at] => 2017-08-17 13:41:25
[updated_at] => 2017-08-17 13:41:25
[status] => 1
[cost_code] => P0035
[weight] => 0.00
[deleted_at] =>
[active_from] => 0000-00-00
[inactive_from] => 0000-00-00
[asset] => Array
(
[id] => 5
[name] => 0.5m Planer
[default_rate] =>
[tax_id] => 1
[nominal_code] => 00002
[created_at] => 2017-07-24 20:41:45
[updated_at] => 2018-06-12 17:26:23
[status] => 1
[weekday_am] => 190
[weekday_pm] => 190
[weekend_am] => 190
[weekend_pm] => 190
[group_id] => 3
[cost_weekday_am] => 152
[cost_weekend_am] => 152
[cost_weekend_pm] => 152
[cost_weekday_pm] => 152
[project_code] =>
[manufacturer] =>
[model] =>
[purchase_date] => 0000-00-00
[warranty_expiry] =>
[mot_due] =>
[group] => Array
(
[id] => 3
[name] => Planers
[status] => 1
[created_at] => 2017-07-14 17:21:49
[updated_at] => 2017-07-14 17:21:49
)
)
[asset_id_allocations] => Array
(
)
)
[6] => Array
(
[id] => 30
[asset_id] => 6
[description] => PL12
[created_at] => 2017-08-17 13:41:40
[updated_at] => 2017-08-17 13:41:40
[status] => 1
[cost_code] => P0036
[weight] => 0.00
[deleted_at] =>
[active_from] => 0000-00-00
[inactive_from] => 0000-00-00
[asset] => Array
(
[id] => 6
[name] => 1m Planer
[default_rate] =>
[tax_id] => 1
[nominal_code] => 00002
[created_at] => 2017-07-24 20:42:06
[updated_at] => 2019-02-12 18:38:20
[status] => 1
[weekday_am] => 309.31
[weekday_pm] => 309.31
[weekend_am] => 309.31
[weekend_pm] => 309.31
[group_id] => 3
[cost_weekday_am] => 247.45
[cost_weekend_am] => 247.45
[cost_weekend_pm] => 247.45
[cost_weekday_pm] => 247.45
[project_code] =>
[manufacturer] =>
[model] =>
[purchase_date] => 1970-01-01
[warranty_expiry] =>
[mot_due] =>
[group] => Array
(
[id] => 3
[name] => Planers
[status] => 1
[created_at] => 2017-07-14 17:21:49
[updated_at] => 2017-07-14 17:21:49
)
)
[asset_id_allocations] => Array
(
)
)
)
Код лезвия:
@php $asset_category_id = 0; @endphp
@foreach($asset_array as $key=>$final)
<tr>
normal row
</tr>
@if($asset_category_id != trim($final['asset']['id']))
<tr>
Unallocated row
</tr>
@endif
@php $asset_category_id = $final['asset']['id']; @endphp
@endforeach
Любые предложения, чтобы решить эту проблему?