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

To add support for css classes for w2ui grid #1063

Closed
toextendmylimits opened this issue Oct 15, 2015 · 2 comments
Closed

To add support for css classes for w2ui grid #1063

toextendmylimits opened this issue Oct 15, 2015 · 2 comments

Comments

@toextendmylimits
Copy link

w2ui grid allows to give a row some inline css styles by using style:'inline css styles' shown as follows:
$('#grid').w2grid({
name : 'grid',
columns: [
{ field: 'recid', caption: 'ID', size: '50px' },
{ field: 'lname', caption: 'Last Name', size: '30%' },
{ field: 'fname', caption: 'First Name', size: '30%' },
{ field: 'email', caption: 'Email', size: '40%' },
{ field: 'sdate', caption: 'End Date', size: '120px' }
],
records: [
{ recid: 1, fname: 'John', lname: 'doe', email: 'vitali@gmail.com', sdate: '1/3/2012' ,style:' background-color:red'},
{ recid: 2, fname: 'Stuart', lname: 'Motzart', email: 'jdoe@gmail.com', sdate: '2/4/2012',style: 'background-color:green '}
]
});
However, w2ui doen't allow to use css classes to style a row, like:
...
records: [
{ recid: 1, fname: 'John', lname: 'doe', email: 'vitali@gmail.com', sdate: '1/3/2012' ,class:' className1 className2'}]

Wouldn't it be nice to add this feature since css classes give us more freedom to change styles via external style sheet and also allow styles to be shared by different grids easily?

@vitmalina
Copy link
Owner

You (possibly) bring a good point. The reason style was added is because it was for extra styling you want to add that is not standard. You can also use render function for the column and then you can make it what ever you want and add classes. Over many years I struggle with what is the best use of CSS and styles and I am preferring to use CSS for standard styles and not for exceptions. If I need to add some exceptional styling (for a specific element), I now prefer not to polute my CSS (otherwise it because exceptionaly "dirty" and hard to maintain).

Another point is that style property exists in many other places. In toolbars, sidebars, layout panels. It makes is uniform across the library.

Another point is that recently, I have added formatters. You can add anything to w2utils.formatters (which is an object) and then in columns use render: 'formatter_name:params'. I have refactored all formatters that grid used to use, such as 'date', 'datetime', 'age', 'size', etc. This provides a better way to add custom renderers. And I am hoping to use formatters in other places.

Well, I will think about it some more.

@ltdl
Copy link

ltdl commented Jun 9, 2016

It would by nice to have. Much cleaner. I use my custom responsive grid layout build on top of w2ui. Like adding different styling for toolbars, forms or panels across project. By now I use this approach:

onRender: function(event) { event.onComplete = function() { $('[name="toolbarMain"]').addClass('toolbar-widget'); } },

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

No branches or pull requests

3 participants