Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pass classes, when creating table through array? #7

Open
jonasinlu opened this issue Jan 8, 2016 · 6 comments
Open

How to pass classes, when creating table through array? #7

jonasinlu opened this issue Jan 8, 2016 · 6 comments

Comments

@jonasinlu
Copy link

$table = Table::create($rows, [
'id' => '',
'name' => ['label' => trans('projects.index_label_name'), 'class' => 'test-class'],
'estimate' => trans('projects.index_label_estimate'),
'asignees' => trans('projects.index_label_asignees'),
'status' => trans('projects.index_label_status'),
'start' => trans('projects.index_label_start'),
'end' => trans('projects.index_label_end'),
]);

in this example, i'm trying to achieve the same thing as in example that you have provided with addClass() method:

$table->addColumn('status_id', trans('tasks.status'), function($model) {
return $model->getStatusName();
})->addClass('fw-150 hidden-xs');

is this possible with current release or do you plan on extending this library in future to support this?

@gbrock
Copy link
Owner

gbrock commented Jan 15, 2016

Currently, adding classes is only supported when adding columns programmatically (i.e. using addColumn(). I'll consider it for a future release. Thanks for providing a code sample of how you'd expect such a feature to work!

@jonasinlu
Copy link
Author

well this change would make controller action much cleaner to read the code, and actual example of this table creation with array would make more sense compared to that separate column addition.

but all in all, thank you for providing such useful code for open public, this saves so much time when trying to add fast sorting to your project. i hope, that this would become more popular in future, because i just couldn't find anything similar to this :)

thank you for your great contribution!

@gbrock
Copy link
Owner

gbrock commented Jan 15, 2016

Thank you for the kind words!

Considering this further, I probably wouldn't use it that way; I like keeping controllers as simple as possible, while putting every bit of HTML and HTML logic within view files. But, I also appreciate that everyone does things in their own way, and more options is never a bad thing. 👍

@jonasinlu
Copy link
Author

well, actually the correct way (atleast from my perspective) is to place the query for data inside controller (as little as possible), and then worry about the display itself in the view files. that building of columns might be logical inside views, but i like to give structured data from controller and the view files control only the display, not what to display and what not. but you are right, everyone has their own style, and if there are more customization - it's only for the better. i hope you will keep this library alive, but i also know that such things cost time and you are not getting anything back, just kind words. but people like you are the ones who make programming such an awesome experience ;)

@drclaw
Copy link

drclaw commented Apr 21, 2017

Wouldn't it just work if you used the classes key in your fields array rather than class? Since setParameters() builds the method name out from the key, and there is a setClasses() method already?

@brynj-digital
Copy link

I can confirm what drclaw suggests - it works if you use classes as the key

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants