Skip to content

Commit 73afad5

Browse files
authored
chore(*): Adjust styles and sizes for row pinning custom sample (#966)
* chore(*): Adjust styles and sizes. * Try with different tags. * Check if selector break logic that puts it in css. * Try with another tag. * Try another combination. * Try with more tags. * Try with another tag. * Try with a separate template just for styles. * Apply classes to other templates as well. * Set template without initial call. * Hide icon from template in ghost row in WC/React. * Remove conditional template as it does not work with index check for some reason in React. Use key instead when toggling pinning. * Remove toArray since response is already unwrapped to array in wc. * Add a markForCheck to ensure everything updates after pin. * Bump up react version.
1 parent d9fc4eb commit 73afad5

7 files changed

Lines changed: 68 additions & 6 deletions

File tree

code-gen-library/WebGridRowPinCellTemplate/Blazor.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ igRegisterScript("WebGridRowPinCellTemplate", (ctx) => {
55
var grid = document.getElementsByTagName("igc-grid")[0];
66
grid.getRowByIndex(index).pinned = !grid.getRowByIndex(index).pinned;
77
}
8+
var grid = document.getElementsByTagName("igc-grid")[0];
89
const index = ctx.cell.id.rowIndex;
9-
return html`<div>
10-
<span onpointerdown='toggleRowPin("${index}")'>📌</span>
10+
const row = grid.rowList.toArray().find(x => x.index === index);
11+
if (row && row.pinned && row.disabled) {
12+
return html``;
13+
}
14+
return html`<div class='customIcon'>
15+
<span class='customIconSpan' onpointerdown='toggleRowPin("${index}")'>📌</span>
1116
</div>`;
1217
}, false);
1318
//end template

code-gen-library/WebGridRowPinCellTemplate/React.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,24 @@ export class WebGridRowPinCellTemplate {
66
//begin template
77
//begin content
88
public webGridRowPinCellTemplate = (e: {dataContext: IgrCellTemplateContext}) => {
9+
const grid = CodeGenHelper.getDescription<IgrGrid>("content");
910
const index = e.dataContext.cell.row.index;
11+
const row = grid.rowList.toArray().find(x => x.index === index);
12+
if (row && row.pinned && row.disabled) {
13+
return (<></>);
14+
}
1015
return (
11-
<span onPointerDown={(e: any) => this.toggleRowPin(index)} style={{ cursor: 'pointer'}}>📌</span>
16+
<div className='customIcon'>
17+
<span onPointerDown={(e: any) => this.toggleRowPin(index)} className='customIconSpan'>📌</span>
18+
</div>
1219
);
1320
}
1421
//end content
1522
//begin supportingMethods
1623
public toggleRowPin(index: number) {
1724
let grid = CodeGenHelper.getDescription<IgrGrid>("content");
1825
grid.getRowByIndex(index).pinned = !grid.getRowByIndex(index).pinned;
26+
grid.markForCheck();
1927
}
2028
//end supportingMethods
2129
//end template

code-gen-library/WebGridRowPinCellTemplate/WebComponents.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,19 @@ export class WebGridRowPinCellTemplate {
1010
//begin content
1111
public webGridRowPinCellTemplate = (ctx: IgcCellTemplateContext) => {
1212
const index = ctx.cell.id.rowIndex;
13-
return html`<span @pointerdown=${(e: any) => this.toggleRowPin(index)}>📌</span>`
13+
const grid = CodeGenHelper.getDescription<IgcGridComponent>("content");
14+
const row = grid.rowList.find((x:any) => x.index === index);
15+
if (row && row.pinned && row.disabled) {
16+
return html``;
17+
}
18+
return html`<div class='customIcon'><span class='customIconSpan' @pointerdown=${(e: any) => this.toggleRowPin(index)}>📌</span></div>`
1419
}
1520
//end content
1621
//begin supportingMethods
1722
public toggleRowPin(index: number) {
1823
var grid = CodeGenHelper.getDescription<IgcGridComponent>("content");
1924
grid.getRowByIndex(index).pinned = !grid.getRowByIndex(index).pinned;
25+
grid.markForCheck();
2026
}
2127
//end supportingMethods
2228
//end template
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//begin eventHandler
2+
igRegisterScript("WebGridRowPinCellTemplateStyles", (args) => {
3+
//OMIT HANDLER
4+
}, false);
5+
//end eventHandler
6+
7+
let requiredStyles = `
8+
<!--begin styles-->
9+
.customIcon {
10+
display: flex;
11+
width: 100%;
12+
justify-content: center;
13+
}
14+
15+
.customIconSpan {
16+
cursor: pointer;
17+
}
18+
<!--end styles-->
19+
`;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//begin imports
2+
//end imports
3+
4+
export class WebGridRowPinCellTemplateStyles {
5+
//begin eventHandler
6+
public webGridRowPinCellTemplateStyles(): void {
7+
//OMIT HANDLER
8+
}
9+
//end eventHandler
10+
public requiredStyles = `
11+
<!--begin styles-->
12+
.customIcon {
13+
display: flex;
14+
width: 100%;
15+
justify-content: center;
16+
}
17+
18+
.customIconSpan {
19+
cursor: pointer;
20+
}
21+
<!--end styles-->
22+
`;
23+
}

editor-templates/React/main-template/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"igniteui-react-gauges": "19.3.1",
4040
//endifdef gauges, dashboards
4141
//ifdef webgrids
42-
"igniteui-react-grids": "^19.4.0",
42+
"igniteui-react-grids": "^19.5.0-beta.0 ",
4343
//endifdef webgrids
4444
//ifdef grid, dashboards
4545
"igniteui-react-data-grids": "19.3.1",

samples/grids/grid/row-pinning-extra-column.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"TODO add event to handle row pinning"
44
],
55
"skipAlterDataCasing": true,
6+
"onInit": ["WebGridRowPinCellTemplateStyles"],
67
"descriptions": {
78
"content": {
89
"name": "grid",
@@ -13,7 +14,7 @@
1314
"columnList": [
1415
{
1516
"type": "WebColumn",
16-
"width": "70px",
17+
"width": "100px",
1718
"filterable": false,
1819
"pinned": true,
1920
"bodyTemplateRef": "WebGridRowPinCellTemplate"

0 commit comments

Comments
 (0)