-
Notifications
You must be signed in to change notification settings - Fork 0
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
My edited version #10
Comments
Thanks for the feedback!
That is indeed a good idea. I see the same advantages you pointed out. Only downside is that this is breaking backwards compatibility, so we need a new major version. I'll merge #8 first, push a new version and work on a
Also a good point. I'll do that in #8
👍 -> #8 let rowDefinition = {
classNames: [
{className: {propertyPath: 'location.postcode'}},
{className: {value: (data, row, rowIndex) => (rowIndex + 1) % 2 === 0 ? data.last_name : ""}},
{className: {value: (data, row, rowIndex) => data.title === "mr" ? "male my-other-class" : ""}},
],
}; we can do let rowDefinition = {
classNames: [
'my-row-class',
{propertyPath: 'location.postcode'},
{value: (data, rowIndex) => (rowIndex + 1) % 2 === 0 ? data.last_name : ""},
{value: (data, rowIndex) => data.title === "mr" ? "male my-other-class" : ""},
],
};
Yes. This is a hack. Not sure if it wasn't possible in the past, or if there is a better was nowadays. I'll address this in a separate issue.
Actually, I have around 12 columns in my side project (some heavy tables there) where I extracted this library from. So the step to 20 columns was not that far.
👍 -> #8
No worries. I appreciate your feedback 😃 |
Nice change on row def structure. Glad it helps. |
Closing it, as it can still be referenced. |
Just want to give back and share my edited version I'm using locally and point out some highlights and why's of the changes.
https://gist.github.com/fuzzthink/2b39d046ea1efca393623fc8c0af5687
Highlights of changes:
config
object with key-vals ofcolumns
,rows
, and pretty much all other configs. I've only addedmultisort
because I want to override it to false.rowsCfg.forEach((cfg) =>
,{#each config.columns as cfg, iCol}
,cfg.something
, etc. This makes reading the code much easier as it takes no brain power to see it is a config, whereascolumn.something
androw.something
does -- it takes that extra brain power to recall it's config, and that's not a good thing. Yes, the code can be changed to this w/o changing the interface, but why not introduce this benefit to the caller too?<ExtTable data={rows} {config}>
. And definition of config is clearly about config as well.?.
to simplify the logic. The current PR can be much easier to read with?.
. Take a look at tableClassNames.js, the logic is just 4 flat conditionals, no need for nesting ifs.on:click|stopPropagation
and one doesn't is code smell to me. 90% of errors happens because we forget to apply the same fix needed to all the different places. I'm probably missing the need for the stopPropagation, but until I run into that problem, I'm not going to let that mess up my code. And if I do run into it, I believe there should be better solutions.const
overlet
to show intention, usingif (...)
instead of(...) &&
-- much easier to read imho, seetableClassNames.js
, and using ternaries more (getOddEvenClass
).With these changes, the main file is just 200 lines and 260 if classNames logic is not extracted. More importantly is readability, which imho, has been enhanced.
Please don't take this the wrong way, I've already mentioned how much I like your library. Just want to share my thoughts so you can take some of these suggestions if you think they are sound.
The text was updated successfully, but these errors were encountered: