primeng icon indicating copy to clipboard operation
primeng copied to clipboard

Row hovered should call an event so I can show something at the table.

Open Galiza opened this issue 9 years ago • 11 comments

There is no guarantee in receiving a response in GitHub Issue Tracker, If you'd like to secure our response, you may consider PrimeNG PRO Support where support is provided within 4 business hours

I'm submitting a ... (check one with "x")

[ ] bug report => Search github for a similar issue or PR before submitting
[X] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Current behavior The behavior wanted is not supported.

What is the motivation / use case for changing the behavior? The motivation is that I need to hover throught a ROW, and I need that when the HOVER happens two buttons should appear at the end of the table.

  • Angular version: 5.0.0

  • PrimeNG version: 4.3.0

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ] All of them.

  • Node (for AoT issues): node --version = v6.10.0

Galiza avatar Nov 13 '17 17:11 Galiza

What's wrong with only using CSS to do that? Here's a quick example.

dzhavat avatar Nov 13 '17 20:11 dzhavat

The problem is that I'm using the p-dataTable in multiple places, if I override the CSS either using /deep/ or placing into a global CSS, all my tables will act accordingly, but I want to use it in just one place. Your example indeed works fine, but it's not what I'm looking for.

Galiza avatar Nov 13 '17 21:11 Galiza

I don't think it's necessary to overwrite any CSS. You can add your own only to a specific dataTable component. By specifying style or styleClass properties on a dataTable you can add either inline CSS or a custom class, which you can use in your CSS style sheet. Take a look at the Properties table in the documentation.

dzhavat avatar Nov 13 '17 22:11 dzhavat

@dzhavat I have similar requirement, to display buttons in another column on row hover. Its working via CSS. But when I am hovering on that column (where display buttons are present) its not responding to CSS and is remaining AS IS with plain white background To display buttons, I used Visibility property instead of display property (as display caused some misalignments). Is there anyway to fix my case ?

mani301 avatar Nov 14 '17 16:11 mani301

Well, you do actually, because using styleClass you'll be giving the p-column attribute the class you chose, meaning that the tag will be the one having the class. Just as the image below:

style

styleclass

And the style is not setting the class in any element that I choose. So I'm having a bad time because of this. And since (mouseover) or (mouseenter) doesn't work on the p-dataTable or p-column you can see where I'm getting at. And using tr:hover or anything like that at the local scss doesn't work.

If any of you have any other suggestion that I should try, please, do suggest.

Galiza avatar Nov 14 '17 18:11 Galiza

I was able to use the rowStyleClass and then use a certain style at every row. And then using what @dzhavat showed at codepen I was able to to in part what I wanted. Still, definitely not the best way of using it.

Galiza avatar Nov 14 '17 19:11 Galiza

@Galiza Why don't you put a class on the dataTable with styleClass and then use that class in your CSS.

Something like:

.myDataTable tr button {
  display: none;
}

.myDataTable tr:hover button {
  display: inline-block;
}

dzhavat avatar Nov 14 '17 21:11 dzhavat

@dzhavat Because when you place the styleClass on the dataTable, the tag that gets the css class is the , so I suppose it won't work if I try to access a class that's inner than and then invoke after in css. Or am I mistaken?

Galiza avatar Nov 14 '17 21:11 Galiza

@Galiza I've created a simple a Plunkr example showing a way to do what you need (at least that's the way I understood it from your description).

The important thing to note is encapsulation: ViewEncapsulation.None inside the app/app.component.ts file. Removing this line will make the button not show on hover.

The reason this is working is because encapsulation: ViewEncapsulation.None disables the style encapsulation, which Angular applies on every component.

dzhavat avatar Nov 15 '17 12:11 dzhavat

@dzhavat Well, that's some nice example there, and now I get what you meant. Thank you very much!

Galiza avatar Nov 16 '17 14:11 Galiza

We rather not provide a built-in solution as it will break the performance due to constant change detection of Angular on rowHover.

cagataycivici avatar Nov 17 '17 10:11 cagataycivici