Как изменить цвет каждой записи CRUD при включении таблицы Ajax?Php

Кемеровские программисты php общаются здесь
Ответить
Anonymous
 Как изменить цвет каждой записи CRUD при включении таблицы Ajax?

Сообщение Anonymous »

Я использую рюкзак Laravel и недавно включил $ this-> crud-> enableajaxtable (); < /code> в моем Crud, потому что было много данных, чтобы показать. < /p>

Но теперь я не могу раскрасить свои записи CRUD в зависимости от expiry_date, как я делал раньше, переопределив list.blade.php />@if (!$crud->ajaxTable())
@foreach ($entries as $k => $entry)




< /code>

Может быть, из -за этого: < /p>

@if (!$crud->ajaxTable())
< /code>

Я попытался настроить поисковый запрос ajaxtable.php < /strong>, используя эту ссылку, но я не был успешным. Вот код, который я попробовал в своем примере CexampleCrudController, переоценив поисковый запрос AJAX: < /p>

public function search()
{
$this->crud->hasAccessOrFail('list');

// create an array with the names of the searchable columns
$columns = collect($this->crud->columns)
->reject(function ($column, $key) {
// the select_multiple, model_function and model_function_attribute columns are not searchable
return isset($column['type']) && ($column['type'] == 'select_multiple' || $column['type'] == 'model_function' || $column['type'] == 'model_function_attribute');
})
->pluck('name')
// add the primary key, otherwise the buttons won't work
->merge($this->crud->model->getKeyName())
->toArray();

// structure the response in a DataTable-friendly way
$dataTable = new \LiveControl\EloquentDataTable\DataTable($this->crud->query, $columns);

// make the datatable use the column types instead of just echoing the text
$dataTable->setFormatRowFunction(function ($entry) {

$today_date = Carbon::now();

$data_difference = $today_date->diffInDays(Carbon::parse($entry->expiry_date), false);

if($data_difference = 0) {
$color="#FF9900";
} elseif($data_difference < 0) {
$color="#EA2C12";
} elseif($data_difference > 7) {
$color="#539E05";
}

// get the actual HTML for each row's cell
$row_items = $this->crud->getRowViews($entry, $this->crud, $color);

// add the buttons as the last column
if ($this->crud->buttons->where('stack', 'line')->count()) {
$row_items[] = \View::make('crud::inc.button_stack', ['stack' => 'line'])
->with('crud', $this->crud)
->with('entry', $entry)
->render();
}

// add the details_row buttons as the first column
if ($this->crud->details_row) {
array_unshift($row_items, \View::make('crud::columns.details_row_button')
->with('crud', $this->crud)
->with('entry', $entry)
->render());
}

return $row_items;
});

return $dataTable->make();
}
< /code>

Итак, мой вопрос заключается в том, как я могу раскрасить свои записи CRUD в зависимости от expiry_date, когда eNableJaxtable активен в рюкзаке Laravel? < /p>

Подробнее здесь: https://stackoverflow.com/questions/470 ... is-enabled
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Php»