MedicOneSystems / MedicOneSystems/livewire-datatables
View parameters..?
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 1.2k
- Forks
- 257
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I'm playing around a bit with this package, great work so far!
I've noticed a few things missing that others might find useful as well, one of those things are "view parameters".
Your current view() method hardcodes which parameters are available in the view, namely value and row.
My suggestion is to either pass an additional parameter to the function like:
view('myview', $params)
or to set it via an additional function, this is how I did it for my needs, keep in mind this is a dirty "hack" so I haven't checked in much detail if there is a better way perhaps:
`class ExtendedColumn extends Column
{
public $viewParameters;
public function viewParameters($parameters)
{
$this->viewParameters = $parameters;
return $this;
}
public function view($view)
{
$this->callback = function ($value, $row) use ($view) {
$params = array_merge(['value' => $value, 'row' => $row, 'name' => $this->name], $this->viewParameters);
return view($view, $params);
};
return $this;
}`
This enables me to have custom editing with a select instead of a default input field for example but it also enables other things as well...
ExtendedColumn::name('status')
->viewParameters(['options' => Invoice::STATUSES, 'table' => $this->table])
->view('datatables::editable-select'),
Let me know what do you think of this idea and if you want I can submit a PR.
I'm toying around with some other stuff as well but I'll keep that in a separate issue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the current view() method, which hardcodes value and row as the available parameters, and review how the rendered view receives them. Done means callers can provide additional parameters for custom views while retaining the existing parameters.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- laravel, php
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100