Я использую рюкзак 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
Как изменить цвет каждой записи CRUD при включении таблицы Ajax? ⇐ Php
Кемеровские программисты php общаются здесь
-
Anonymous
1740537563
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>
Подробнее здесь: [url]https://stackoverflow.com/questions/47048791/how-to-change-the-color-of-each-crud-entry-when-ajax-table-is-enabled[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия