Tino Posted September 7, 2022 Share Posted September 7, 2022 Hi, I have a MarkupAdminDataTable and each row contains an edit-link of the entry. $table->row([$guest->title => $guest->editUrl, ...]); But I don't want the edit window to open, instead I want to use the "pw-panel" Class and after saving the modification the page need to be reloaded also. I don't know how to include addClass('pw-panel'); https://processwire.com/api/ref/markup-admin-data-table/row/ Quote Array of columns that will each be a <td>, where each element may be one of the following: string: converts to <td>string</td> $a["key"] = "value": converts to <td><a href='value'>key</a></td> array('label' => 'url'): converts to <td><a href='url'>label</a></td> (same as above, but in nested array with count 1) array('label', 'class'): converts to <td class='class'>label</td> But I need a combination of the last two options like this: $table->row([array($guest->title => $guest->editUrl, 'pw-panel'), ...]); but than only 'pw-panel' get written in the field, no title and no url... I tried also to put the 'pw-panel' class to the complete <tr> but that in't doing the job either. $table->row([$guest->title => "$guest->editUrl", ...], ['class'=>'pw-panel']); Thank you Link to comment Share on other sites More sharing options...
gebeer Posted September 8, 2022 Share Posted September 8, 2022 Hi, you need to construct the HTML for the link when building the array that you pass to $table->row and set $table->encodeEntities = false; In this example I am building the rows from a pro field table: /** @var TableRows $transactions */ $transactions = $this->wire('pages')->get('template=membership')->membership_transactions; /** @var MarkupAdminDataTable $table */ $table = $this->wire('modules')->get('MarkupAdminDataTable'); $table->addClass('AdminDataList table-striped'); $table->sortable = true; $table->encodeEntities = false; // important $table->headerRow($transactions->getLabels()); /** @var TableRow $t */ foreach ($transactions as $t) { $row = array(); foreach ($t->getArray() as $key => $val) { if ($key == 'id') continue; if ($key == 'member') $val = "<a class='pw-panel' href='{$val->editUrl}'>$val->fullname</a>"; // construct your link here if ($key == 'amount') $val = $val . ' USD'; if ($key == 'date') $val = date('Y-m-d h:i', $val); if ($key == 'status') $val = ($val) ? 'success' : 'failure'; $row[] = $val; } // bd($row); $table->row($row); } return $table->render(); Hope that helps. Link to comment Share on other sites More sharing options...
Tino Posted September 8, 2022 Author Share Posted September 8, 2022 Hi, $table->encodeEntities = false; did the job in combination with a proper html for the table row. <a class='pw-panel' href= ...> Thank you very much! Sometimes the solution is so simple, I already tried to use HTML with buttons and stuff like that but you put me on the right track. Have a nice day! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now