yii-dataview icon indicating copy to clipboard operation
yii-dataview copied to clipboard

GridView - can't set css class on tbody when empty rows

Open uaoleg opened this issue 8 years ago • 2 comments

Render GridView widget with empty rows and table bootstrap class table table-hover

tbody (which contains $emptyText) changes it's background color on hover but I can't control that, because class empty is assigned to the div inside tbody

emptyTextOptions should be assigned to the tbody instead of div inside it

empty

Q A
Yii version 2.0.?
PHP version 7.0
Operating system Windows

uaoleg avatar Oct 31 '17 07:10 uaoleg

@samdark https://github.com/yiisoft/yii2/blob/46b9d607a25769c8554773291698c4f6ec654187/framework/grid/GridView.php#L481-L485

we have BC broken

bscheshirwork avatar Nov 02 '17 07:11 bscheshirwork

You can use any stronger CSS selector for overriding default styles. E.g. you may use

  • outer wrapper's ID (#js-tourists-table tbody tr),
  • attribute selector e.g. table td[colspan=2],
  • pseudoselectors like :first-child, tbody > tr:nth-of-type(odd)
  • combined tags & classes etc ...

Bootstrap is designed with low specificity to enable quite easy overriding. See how CSS power/priority/hierarchy/specifity is calculated

  • https://stackoverflow.com/questions/4072365/css-understanding-the-selectors-priority-specificity
  • https://www.w3.org/TR/css3-selectors/#specificity

lubosdz avatar Nov 02 '17 23:11 lubosdz

Works alright in current master.

samdark avatar Sep 04 '24 13:09 samdark

See https://github.com/yiisoft/yii-dataview/blob/master/src/GridView.php#L634

samdark avatar Sep 04 '24 13:09 samdark