rapyd-laravel
rapyd-laravel copied to clipboard
DataGrid function attributes and style
Hi,
I am tryin to customize a DataGrid, with your base example:
$grid->row(function ($row) {
if ($row->cell('public')->value < 1) {
$row->cell('title')->style("color:Gray");
$row->style("background-color:#CCFF66");
}
});
I need to add several attributes to my row, because I want something like:
<tr style="background-color:#CCFF66" data-toggle="collapse">
Good news, there is a function which works well 👍
attributes(['data-toggle' => 'collapse'])
My problem is that this method erases all the previous attributes. So if I do something like:
$grid->row(function ($row) {
if ($row->cell('public')->value < 1) {
$row->cell('title')->style("color:Gray");
$row->style("background-color:#CCFF66");
$row->attributes(['data-toggle' => 'collapse']);
}
});
The attribute "style" will be erased.
I can do a fix if needed. multiple solutions:
A) Don't fix anything, you have to be careful and always declare the style at the end, so it won't be erased B) Add an array_merge function in the attributes function (but breaking change? If someone has the strange idea to call the attributes() function without arguments to clear the styles, it will break his code) C) Change the style behaviour, and don't use attributes variable D) Add an additional function "addAttribute" E) Add an argument to the function attributes (merge true/false)
Btw, the solution A is ready to merge 👍
I want do the same
i cant set attributes in $grid->add?