diff --git a/samples/charts/data-chart/data-annotation-band-layer/src/index.tsx b/samples/charts/data-chart/data-annotation-band-layer/src/index.tsx index 8aea3a77b..d9d2c179f 100644 --- a/samples/charts/data-chart/data-annotation-band-layer/src/index.tsx +++ b/samples/charts/data-chart/data-annotation-band-layer/src/index.tsx @@ -27,32 +27,19 @@ export default class Sample extends React.Component { private chartRef(r: IgrDataChart) { this.chart = r; this.setState({}); - } - private xAxisBottom: IgrCategoryXAxis - private xAxisBottomRef(r: IgrCategoryXAxis){ - this.xAxisBottom = r; - this.setState({}); } + private xAxisBottom: IgrCategoryXAxis private xAxis: IgrCategoryXAxis private yAxisLeft: IgrNumericYAxis private yAxisRight: IgrNumericYAxis private series1: IgrFinancialPriceSeries private tooltip: IgrDataToolTipLayer private bandLayer: IgrDataAnnotationBandLayer - private bandLayerRef(r: IgrDataAnnotationBandLayer) { - this.bandLayer = r; - this.setState({}); - } constructor(props: any) { super(props); this.chartRef = this.chartRef.bind(this); - this.bandLayerRef = this.bandLayerRef.bind(this); - this.xAxisBottomRef = this.xAxisBottomRef.bind(this); - } - componentDidMount(): void { - this.bandLayer.targetAxis = this.xAxisBottom; } public render(): JSX.Element { @@ -80,7 +67,6 @@ export default class Sample extends React.Component { chartTitle="Data Chart with DataAnnotationBandLayer bound to data that annotates stock rapid growth"> { { private chartRef(r: IgrDataChart) { this.chart = r; this.setState({}); - } - private xAxis: IgrCategoryXAxis - private xAxisRef(r: IgrCategoryXAxis){ - this.xAxis = r; - this.setState({}); } + private xAxis: IgrCategoryXAxis private yAxisLeft: IgrNumericYAxis private yAxisRight: IgrNumericYAxis - private yAxisRightRef(r: IgrNumericYAxis){ - this.yAxisRight = r; - this.setState({}); - } private series1: IgrFinancialPriceSeries private tooltip: IgrDataToolTipLayer private lineLayer52WeekRange: IgrDataAnnotationLineLayer - private lineLayer52WeekRangeRef(r: IgrDataAnnotationLineLayer){ - this.lineLayer52WeekRange = r; - this.setState({}); - } private lineLayerGrowthAndDecline: IgrDataAnnotationLineLayer - private lineLayerGrowthAndDeclineRef(r: IgrDataAnnotationLineLayer){ - this.lineLayerGrowthAndDecline = r; - this.setState({}); - } + constructor(props: any) { super(props); this.chartRef = this.chartRef.bind(this); - this.xAxisRef = this.xAxisRef.bind(this); - this.yAxisRightRef = this.yAxisRightRef.bind(this); - this.lineLayer52WeekRangeRef = this.lineLayer52WeekRangeRef.bind(this); - this.lineLayerGrowthAndDeclineRef = this.lineLayerGrowthAndDeclineRef.bind(this); - } - componentDidMount(): void { - this.lineLayer52WeekRange.targetAxis = this.yAxisRight; - this.lineLayerGrowthAndDecline.targetAxis = this.xAxis; } + public render(): JSX.Element { return (
@@ -90,7 +68,6 @@ export default class Sample extends React.Component { chartTitle="The Data Chart demonstrates the DataAnnotationLineLayer bound to data that annotates stock growth and decline patterns."> { { { { } private xAxis: IgrCategoryXAxis private yAxis: IgrNumericYAxis - private yAxisRef(r: IgrNumericYAxis) { - this.yAxis = r; - this.setState({}); - } private series1: IgrLineSeries private valueOverlay: IgrValueOverlay private valueLayer: IgrValueLayer private annoLayer: IgrDataAnnotationSliceLayer - private annoLayerRef(r: IgrDataAnnotationSliceLayer){ - this.annoLayer = r; - this.setState({}); - } constructor(props: any) { super(props); this.chartRef = this.chartRef.bind(this); - this.yAxisRef = this.yAxisRef.bind(this); - this.annoLayerRef = this.annoLayerRef.bind(this); - } - componentDidMount(): void { - this.annoLayer.targetAxis = this.yAxis; } public render(): JSX.Element { @@ -73,7 +60,6 @@ export default class Sample extends React.Component { { { this.setState({}); } private xAxisBottom: IgrCategoryXAxis - private xAxisBottonRef(r: IgrCategoryXAxis){ - this.xAxisBottom = r; - this.setState({}); - } private xAxis: IgrCategoryXAxis - private xAxisRef(r: IgrCategoryXAxis){ - this.xAxis = r; - this.setState({}); - } private xAxisTop: IgrCategoryXAxis - private xAxisTopRef(r: IgrCategoryXAxis){ - this.xAxisTop = r; - this.setState({}); - } private yAxisLeft: IgrNumericYAxis - private yAxisLeftRef(r: IgrNumericYAxis){ - this.yAxisLeft = r; - this.setState({}); - } private yAxisRight: IgrNumericYAxis - private yAxisRightRef(r: IgrNumericYAxis){ - this.yAxisRight = r; - this.setState({}); - } private series1: IgrFinancialPriceSeries private tooltip: IgrDataToolTipLayer private stripLayer: IgrDataAnnotationStripLayer - private stripRef1(r: IgrDataAnnotationStripLayer){ - this.stripLayer = r; - this.setState({}); - } private lineLayer52WeekRange: IgrDataAnnotationLineLayer - private lineRef1(r: IgrDataAnnotationLineLayer){ - this.lineLayer52WeekRange = r; - this.setState({}); - } private lineLayerGrowthAndDecline: IgrDataAnnotationLineLayer - private lineRef2(r: IgrDataAnnotationLineLayer){ - this.lineLayerGrowthAndDecline = r; - this.setState({}); - } private sliceLayerStockSplit: IgrDataAnnotationSliceLayer - private sliceRef1(r: IgrDataAnnotationSliceLayer){ - this.sliceLayerStockSplit = r; - this.setState({}); - } private sliceLayerEarningsMissAnnotations: IgrDataAnnotationSliceLayer - private sliceRef2(r: IgrDataAnnotationSliceLayer){ - this.sliceLayerEarningsMissAnnotations = r; - this.setState({}); - } private sliceLayerEarningsBeatAnnotations: IgrDataAnnotationSliceLayer - private sliceRef3(r: IgrDataAnnotationSliceLayer){ - this.sliceLayerEarningsBeatAnnotations = r; - this.setState({}); - } + constructor(props: any) { super(props); this.chartRef = this.chartRef.bind(this); - this.stripRef1 = this.stripRef1.bind(this); - this.lineRef1 = this.lineRef1.bind(this); - this.lineRef2 = this.lineRef2.bind(this); - this.sliceRef1 = this.sliceRef1.bind(this); - this.sliceRef2 = this.sliceRef2.bind(this); - this.sliceRef3 = this.sliceRef3.bind(this); - this.xAxisRef = this.xAxisRef.bind(this); - this.xAxisBottonRef = this.xAxisBottonRef.bind(this); - this.xAxisTopRef = this.xAxisTopRef.bind(this); - this.yAxisLeftRef = this.yAxisLeftRef.bind(this); - this.yAxisRightRef = this.yAxisRightRef.bind(this); - } - componentDidMount(): void { - this.stripLayer.targetAxis = this.xAxisTop; - this.lineLayer52WeekRange.targetAxis = this.yAxisRight; - this.lineLayerGrowthAndDecline.targetAxis = this.xAxis; - this.sliceLayerStockSplit.targetAxis = this.xAxisBottom; - this.sliceLayerEarningsMissAnnotations.targetAxis = this.xAxisBottom; - this.sliceLayerEarningsBeatAnnotations.targetAxis = this.xAxisBottom; } public render(): JSX.Element { @@ -142,7 +80,6 @@ export default class Sample extends React.Component { chartTitle="This Data Chart has multiple Data Annotation Layers bound to data that annotates important events and patterns in stock prices."> { { { { { layoutMode="Vertical"> { { { { { { this.setState({}); } private xAxis: IgrCategoryXAxis - private xAxisRef(r: IgrCategoryXAxis){ - this.xAxis = r; - this.setState({}); - } private yAxis: IgrNumericYAxis private series1: IgrFinancialPriceSeries private tooltip: IgrDataToolTipLayer private rectLayer: IgrDataAnnotationRectLayer - private rectLayerRef(r: IgrDataAnnotationRectLayer){ - this.rectLayer = r; - this.setState({}); - } constructor(props: any) { super(props); this.chartRef = this.chartRef.bind(this); - this.xAxisRef = this.xAxisRef.bind(this); - this.rectLayerRef = this.rectLayerRef.bind(this); - } - componentDidMount(): void { - this.rectLayer.targetAxis = this.xAxis; } public render(): JSX.Element { @@ -78,7 +65,6 @@ export default class Sample extends React.Component { chartTitle="This Data Chart demonstrates the DataAnnotationRectLayer bound to data that annotates bearish patterns in stock prices."> { { this.setState({}); } private xAxisBottom: IgrCategoryXAxis - private xAxisBottomRef(r: IgrCategoryXAxis){ - this.xAxisBottom =r; - this.setState({}); - } private xAxisTop: IgrCategoryXAxis private yAxisLeft: IgrNumericYAxis private yAxisRight: IgrNumericYAxis private series1: IgrFinancialPriceSeries private tooltip: IgrDataToolTipLayer private sliceLayerStockSplit: IgrDataAnnotationSliceLayer - private sliceLayerStockSplitRef(r: IgrDataAnnotationSliceLayer){ - this.sliceLayerStockSplit = r; - this.setState({}); - } private sliceLayerEarningsMissAnnotations: IgrDataAnnotationSliceLayer - private sliceLayerEarningsMissAnnotationsRef(r: IgrDataAnnotationSliceLayer){ - this.sliceLayerEarningsMissAnnotations = r; - this.setState({}); - } private sliceLayerEarningsBeatAnnotations: IgrDataAnnotationSliceLayer - private sliceLayerEarningsBeatAnnotationsRef(r: IgrDataAnnotationSliceLayer){ - this.sliceLayerEarningsBeatAnnotations = r; - this.setState({}); - } constructor(props: any) { super(props); this.chartRef = this.chartRef.bind(this); - this.sliceLayerStockSplitRef = this.sliceLayerStockSplitRef.bind(this); - this.xAxisBottomRef = this.xAxisBottomRef.bind(this); - this.sliceLayerEarningsMissAnnotationsRef = this.sliceLayerEarningsMissAnnotationsRef.bind(this); - this.sliceLayerEarningsBeatAnnotationsRef = this.sliceLayerEarningsBeatAnnotationsRef.bind(this); - } - - componentDidMount(): void { - this.sliceLayerStockSplit.targetAxis = this.xAxisBottom; - this.sliceLayerEarningsMissAnnotations.targetAxis = this.xAxisBottom; - this.sliceLayerEarningsBeatAnnotations.targetAxis = this.xAxisBottom; } public render(): JSX.Element { @@ -97,7 +71,6 @@ export default class Sample extends React.Component { chartTitle="This Data Chart demonstrates the DataAnnotationSliceLayer bound to data that annotates stock splits and earnings miss/beat events."> { { { { } private xAxisBottom: IgrCategoryXAxis private xAxisTop: IgrCategoryXAxis - private xAxisTopRef(r: IgrCategoryXAxis){ - this.xAxisTop = r; - this.setState({}); - } private yAxisLeft: IgrNumericYAxis private yAxisRight: IgrNumericYAxis private series1: IgrFinancialPriceSeries private tooltip: IgrDataToolTipLayer private stripLayer: IgrDataAnnotationStripLayer - private stripLayerRef(r: IgrDataAnnotationStripLayer){ - this.stripLayer = r; - this.setState({}); - } - componentDidMount(): void { - this.stripLayer.targetAxis = this.xAxisTop; - } constructor(props: any) { super(props); this.chartRef = this.chartRef.bind(this); - this.xAxisTopRef = this.xAxisTopRef.bind(this); - this.stripLayerRef = this.stripLayerRef.bind(this); } public render(): JSX.Element { @@ -89,7 +76,6 @@ export default class Sample extends React.Component { { m.register()); @@ -26,6 +31,7 @@ export default class Sample extends React.Component { super(props); this.gridRef = this.gridRef.bind(this); + this.webGridOnEditEnter = this.webGridOnEditEnter.bind(this); } public render(): JSX.Element { @@ -39,7 +45,8 @@ export default class Sample extends React.Component { ref={this.gridRef} data={this.nwindData} primaryKey="ProductID" - allowFiltering={true}> + allowFiltering={true} + onCellEditEnter={this.webGridOnEditEnter}> @@ -84,6 +91,7 @@ export default class Sample extends React.Component { dataType="number" sortable={true} hasSummary={true} + inlineEditorTemplate={this.webGridNumericColEditCellTemplate} editable={true} filterable={false}> @@ -105,10 +113,46 @@ export default class Sample extends React.Component { var context = this._componentRenderer.context; WebGridDescriptionModule.register(context); WebPaginatorDescriptionModule.register(context); + WebInputDescriptionModule.register(context); } return this._componentRenderer; } + public webGridOnEditEnter(s: IgrGridBaseDirective, e: IgrGridEditEventArgs): void { + + const column = s.getColumnByVisibleIndex(e.detail.cellID.columnID); + if(column.field === 'ReorderLevel') { + setTimeout(() => { + const rowId = e.detail.cellID.rowID; + const columnId = e.detail.cellID.columnID; + const inputTemplateId = `edit-cell-${rowId}-${columnId}`; + const element = document.getElementById(inputTemplateId); + element?.focus(); + }); + } + } + + public webGridNumericColEditCellTemplate = (e: { dataContext: IgrCellTemplateContext }) => { + + const cell = e.dataContext.cell; + const rowId = cell.id.rowID; + const columnId = cell.id.columnID; + const inputTemplateId = `edit-cell-${rowId}-${columnId}`; + + return ( + { + cell.editValue = e.detail; + }} + style={{width: "100%"}} + /> + ); + } + } // rendering above component in the React DOM diff --git a/samples/grids/grid/paste/src/index.tsx b/samples/grids/grid/paste/src/index.tsx index 6d4661a00..5280a0e29 100644 --- a/samples/grids/grid/paste/src/index.tsx +++ b/samples/grids/grid/paste/src/index.tsx @@ -9,7 +9,6 @@ import { IgrGrid, IgrGridToolbar, IgrGridToolbarActions, IgrGridToolbarExporter, import { ComponentRenderer, PropertyEditorPanelDescriptionModule, WebGridDescriptionModule } from 'igniteui-react-core'; import { InvoicesDataItem, InvoicesData } from './InvoicesData'; import { IgrPropertyEditorPropertyDescriptionChangedEventArgs } from 'igniteui-react-layouts'; -import { IgrGridKeydownEventArgs, GridKeydownTargetType } from 'igniteui-react-grids'; import 'igniteui-react-grids/grids/themes/light/bootstrap.css'; import 'igniteui-webcomponents/themes/light/bootstrap.css'; @@ -142,8 +141,8 @@ export default class Sample extends React.Component { (this as any)["pasteMode"] = newVal === "NewRecords" ? "Paste data as new records" : "Paste starting from active cell"; } - public webGridPasteFromExcel() { - const grid = document.getElementById("grid") as any; + public webGridPasteFromExcel(e: any) { + const grid = e.target as IgrGrid; this.onKeyDown = this.onKeyDown.bind(this); grid.addEventListener("keydown", this.onKeyDown); } @@ -313,4 +312,4 @@ export default class Sample extends React.Component { // rendering above component in the React DOM const root = ReactDOM.createRoot(document.getElementById('root')); -root.render(); +root.render(); \ No newline at end of file