Error with beforeColumn and afterColumn methods.
See original GitHub issue(A) what you did
I wanted to add a column at the beginning of the table, so n my CustomCrudController I added a column like this:
$this->crud->addColumn(['label' => "label", 'type' => "text", 'name' => 'name'])->beforeColumn('firstColumn');
(B) what you expected to happen I expected the Column “Name” to be shown at the beginning of the tabel, just before the “firstColumn” column.
© what happened
ErrorException in Columns.php line 92:
array_splice() expects parameter 2 to be long, string given
(D) what have you already tried to fix it? I already submited a PR: https://github.com/Laravel-Backpack/CRUD/pull/472 Changed the beforeColumn and afterColumn methods on /CRUD/src/PanelTraits/Columns.php:
/**
* Moves the recently added column to 'before' the $target_col.
*
* @param $target_col
*/
public function beforeColumn($target_col)
{
foreach ($this->columns as $column => $value) {
if ($value['name'] == $target_col) {
**$offset = array_search($column, array_keys($this->columns));**
array_splice($this->columns, **$offset**, 0, [array_pop($this->columns)]);
break;
}
}
}
/**
* Moves the recently added column to 'after' the $target_col.
*
* @param $target
*/
public function afterColumn($target_col)
{
foreach ($this->columns as $column => $value) {
if ($value['name'] == $target_col) {
**$offset = array_search($column, array_keys($this->columns));**
array_splice($this->columns, **$offset + 1**, 0, [array_pop($this->columns)]);
break;
}
}
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:13 (6 by maintainers)
Top Results From Across the Web
can you specify "after column" with liquibase addColumn?
With Liquibase 3.1 there are new "afterColumn", "beforeColumn" and "position" attributes on the column tag.
Read more >TreeColumns cannot be arranged during runtime | DevExpress ...
Hi Valdemar, I have shifted up the DoLayoutChanged call (after column deletion - before column addition). This way everything works well. Thanks for...
Read more >CREATE MASK statement - IBM
The CREATE MASK statement creates a column mask at the current server. A column mask specifies the value to be returned for a...
Read more >Calc: vlookup produces Er:502 error after column 10 - English
I am trying to post a value from a different sheet using Vlookup and a dropdown list. =(VLOOKUP($A$15,cstmr,11,0)) The dropdown cell is A15....
Read more >ALTER TABLE statement (Microsoft Access SQL)
Use the DAO Create methods instead. ... Attempting to apply this restriction more than once restuls in a run-time error.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @gmedeiros ,
Yup, done in a different commit and issue. All works now, take a look.
Cheers!
@tabacitu, cool, thanks!