-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #81 - Ability to style certain rows and cells in Table
- Loading branch information
1 parent
319a1bc
commit f1f9a23
Showing
6 changed files
with
229 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
<template> | ||
<div> | ||
<DataTableSubMenu /> | ||
|
||
<div class="content-section introduction"> | ||
<div class="feature-intro"> | ||
<h1>DataTable - Style</h1> | ||
<p>Certain rows or cells can easily be styled based on conditions.</p> | ||
</div> | ||
</div> | ||
|
||
<div class="content-section implementation"> | ||
<DataTable :value="cars" :rowClass="rowClass"> | ||
<Column field="vin" header="Vin"></Column> | ||
<Column field="year" header="Year" bodyStyle="padding: 0"> | ||
<template #body="slotProps"> | ||
<div :class="['year-cell', {'old-car': slotProps.data.year < 2010}]"> | ||
{{slotProps.data.year}} | ||
</div> | ||
</template> | ||
</Column> | ||
<Column field="brand" header="Brand"></Column> | ||
<Column field="color" header="Color"></Column> | ||
</DataTable> | ||
</div> | ||
|
||
<div class="content-section documentation"> | ||
<TabView> | ||
<TabPanel header="Source"> | ||
<CodeHighlight> | ||
<template v-pre> | ||
<DataTable :value="cars" :rowClass="rowClass"> | ||
<Column field="vin" header="Vin"></Column> | ||
<Column field="year" header="Year" bodyStyle="padding: 0"> | ||
<template #body="slotProps"> | ||
<div :class="['year-cell', {'old-car': slotProps.data.year < 2010}]"> | ||
{{slotProps.data.year}} | ||
</div> | ||
</template> | ||
</Column> | ||
<Column field="brand" header="Brand"></Column> | ||
<Column field="color" header="Color"></Column> | ||
</DataTable> | ||
</template> | ||
</CodeHighlight> | ||
|
||
<CodeHighlight lang="javascript"> | ||
import CarService from '../../service/CarService'; | ||
|
||
export default { | ||
data() { | ||
return { | ||
columns: null, | ||
cars: null | ||
} | ||
}, | ||
carService: null, | ||
created() { | ||
this.carService = new CarService(); | ||
}, | ||
mounted() { | ||
this.carService.getCarsSmall().then(data => this.cars = data); | ||
}, | ||
methods: { | ||
rowClass(data) { | ||
return data.color === 'Orange' ? 'orange-car': null; | ||
} | ||
} | ||
} | ||
</CodeHighlight> | ||
|
||
<CodeHighlight lang="css"> | ||
.year-cell { | ||
padding: 0.429em 0.857em; | ||
|
||
&.old-car { | ||
background-color: #41b783; | ||
font-weight: 700; | ||
color: #ffffff; | ||
} | ||
} | ||
|
||
/deep/ .orange-car { | ||
background-color: #344b5f !important; | ||
color: #ffffff !important; | ||
} | ||
</CodeHighlight> | ||
</TabPanel> | ||
</TabView> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import CarService from '../../service/CarService'; | ||
import DataTableSubMenu from './DataTableSubMenu'; | ||
export default { | ||
data() { | ||
return { | ||
columns: null, | ||
cars: null | ||
} | ||
}, | ||
carService: null, | ||
created() { | ||
this.carService = new CarService(); | ||
}, | ||
mounted() { | ||
this.carService.getCarsSmall().then(data => this.cars = data); | ||
}, | ||
methods: { | ||
rowClass(data) { | ||
return data.color === 'Orange' ? 'orange-car': null; | ||
} | ||
}, | ||
components: { | ||
'DataTableSubMenu': DataTableSubMenu | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
.year-cell { | ||
padding: 0.429em 0.857em; | ||
&.old-car { | ||
background-color: #41b783; | ||
font-weight: 700; | ||
color: #ffffff; | ||
} | ||
} | ||
/deep/ .orange-car { | ||
background-color: #344b5f !important; | ||
color: #ffffff !important; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters