Skip to content

Commit

Permalink
CSS based row numbering
Browse files Browse the repository at this point in the history
  • Loading branch information
mstijak committed Apr 9, 2020
1 parent 97a3776 commit 88e159f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
12 changes: 6 additions & 6 deletions docs/content/examples/grid/Buffering.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ export const Buffering = <cx>
records:bind="$page.records"
keyField="id"
buffered
style="height: 800px"
style="height: 650px"
mod="fixed-layout"
cached
columns={[
{ header: '#', field: "index", sortable: true, value: { expr: "{$index}+1"}, defaultWidth: 50 },
{ header: '#', defaultWidth: 50, items: <cx><div class="cxe-grid-row-number" /></cx> },
{ header: { text: "Name", style: 'width: 100%' }, field: "fullName", sortable: true, resizable: true },
{ header: "Continent", field: "continent", sortable: true, resizable: true, defaultWidth: 150 },
{ header: "Browser", field: "browser", sortable: true, resizable: true, defaultWidth: 170 },
Expand Down Expand Up @@ -75,20 +75,20 @@ export const Buffering = <cx>
records:bind="$page.records"
keyField="id"
buffered
style="height: 800px"
style="height: 650px"
mod="fixed-layout"
cached
columns={[
{ header: '#', field: "index", sortable: true, value: { expr: "{$index}+1"} },
{ header: '#', defaultWidth: 50, items: <cx><div class="cxe-grid-row-number" /></cx> },
{ header: { text: "Name", style: 'width: 100%' }, field: "fullName", sortable: true, resizable: true },
{ header: "Continent", field: "continent", sortable: true, resizable: true, defaultWidth: 150 },
{ header: "Browser", field: "browser", sortable: true, resizable: true, defaultWidth: 170 },
{ header: "OS", field: "os", sortable: true, resizable: true, defaultWidth: 100 },
{ header: "OS", field: "os", sortable: true, resizable: true, defaultWidth: 80 },
{ header: "Visits", field: "visits", sortable: true, align: "right", resizable: true, defaultWidth: 70 }
]}
selection={{ type: KeySelection, bind: "$page.selection" }}
/>
`}</CodeSnippet>
`}</CodeSnippet>
</CodeSplit>

</Md>
Expand Down
2 changes: 1 addition & 1 deletion packages/cx/src/widgets/grid/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -1745,7 +1745,7 @@ class GridComponent extends VDOM.Component {
return (
<div
className={data.classNames}
style={data.style}
style={{ ...data.style, "counter-reset": `cx-row-number ${start}` }}
tabIndex={
widget.selectable || widget.cellEditable
? data.tabIndex || 0
Expand Down
15 changes: 10 additions & 5 deletions packages/cx/src/widgets/grid/Grid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@
}
}

.#{$element}#{$name}-cell-clip {
overflow: hidden;
text-overflow: ellipsis;
}

&.#{$state}resizable {
.#{$element}#{$name}-data td,
.#{$element}#{$name}-group-footer td,
Expand Down Expand Up @@ -137,6 +132,16 @@
}
}

.#{$element}#{$name}-cell-clip {
overflow: hidden;
text-overflow: ellipsis;
}

.#{$element}#{$name}-row-number::after {
counter-increment: cx-row-number;
content: counter(cx-row-number);
}

.#{$element}#{$name}-fixed-header {
overflow: hidden;
position: absolute;
Expand Down

0 comments on commit 88e159f

Please sign in to comment.