if (this.nodeFromPalette !== '') {
let obj = this.diagram.getObject(this.nodeFromPalette);
let content = (document.getElementById('annotationContent') as HTMLInputElement).value;
if (obj instanceof Node && obj.annotations.length > 0) {
if (content == '') {
this.diagram.remove(obj);
} else{
obj.annotations[0].content = content;
this.diagram.dataBind();
}
}
} |
Hi RakhiS,We have created a sample for your requirements. In the sample, while drag and drop the node from the palette to diagram the “drop” event is triggered. Dialog is open after drop event trigger, by using the dialog box give the content to the annotation for the newly added node. If the annotation’s content is empty, then the node gets removed from the diagram. Otherwise, the node gets added to diagram with given annotation’s content. Please refer to the code snippet in the below table.
if (this.nodeFromPalette !== '') {let obj = this.diagram.getObject(this.nodeFromPalette);let content = (document.getElementById('annotationContent') as HTMLInputElement).value;if (obj instanceof Node && obj.annotations.length > 0) {if (content == '') {this.diagram.remove(obj);} else{obj.annotations[0].content = content;this.diagram.dataBind();}}}For more information about the “drop” event, Please refer to the below documentation link.Documentation Link: https://ej2.syncfusion.com/angular/documentation/api/diagram/iDropEventArgs/We have attached the sample for your reference. Please refer to the sample in the below link.Regards,Suganthi K.
Link Text: | id="annotationContentLink" (focus)='onFocuslnk()' (blur)='onBlurlnk()' name="Required" class="e-input" /> |
public linkPropertiesChange() {
if (this.linkFromPalette !== '') {
let objlnk = this.diagram.getObject(this.linkFromPalette);
this.connectorname = (document.getElementById('annotationContentLink') as HTMLInputElement).value;
if (objlnk instanceof Connector) {
if (this.connectorname == '') {
this.diagram.remove(objlnk);
} else {
objlnk.annotations = [{ content: this.connectorname }];
this.diagram.dataBind();
}
}
}
this.promptDialogLink.hide();
}
|
<ejs-symbolpalette id="symbolpalette" [expandMode]='expandMode' [palettes]='palettes' [getSymbolInfo]='getSymbolInfo' width="100%" height="100%" [symbolHeight]=48
[symbolWidth]=48 [getNodeDefaults]='getSymbolDefaults' [getConnectorDefaults]='getSymbolDefaults'>
</ejs-symbolpalette>
public getSymbolDefaults(symbol: NodeModel): void {
//initialize node annotations
symbol.annotations = [];
} |
Hi below is my all code in detail. my problem is just after this codeThis is the dialog which gets open when a link(connector) drop into the diagram space.---------------------------------------------------------------------step 2:step3step4step5:step6Step7------------------------------------------------------------------------------------------step 8Problem:when I am dropping the link(connector), it opens the pop up but then it also gives error in step 4 "native element of undefined", and when I put any text in the text box and click on submit button, nothing happens. I hope u understand my issue. Please helpThanks
<ejs-symbolpalette id="symbolpalette" [expandMode]='expandMode' [palettes]='palettes' [getSymbolInfo]='getSymbolInfo' width="100%" height="100%" [symbolHeight]=48
[symbolWidth]=48 [getNodeDefaults]='getSymbolNodeDefaults' [getConnectorDefaults]='getSymbolConnectorDefaults'>
</ejs-symbolpalette>
public getSymbolNodeDefaults(symbol: NodeModel): void {
symbol.annotations = [{ style: { color: 'black', fill: 'transparent' } }];
}
public getSymbolConnectorDefaults(symbol: ConnectorModel): void {
symbol.annotations = [{ style: { color: 'black', fill: 'transparent' } }];
}
@ViewChild('password', {static: false})
public password: ElementRef;
@ViewChild('passwordlnk', {static: false})
public passwordlnk: ElementRef;
public linkPropertiesChange() {
if (this.linkFromPalette !== '') {
let obj: ConnectorModel = this.diagram.getObject(this.linkFromPalette);
let content = (document.getElementById('annotationContentLink') as HTMLInputElement).value;
if (content == '') {
this.diagram.remove(obj);
} else{
obj.annotations[0].content = content;
this.diagram.dataBind();
}
(document.getElementById('annotationContentLink') as HTMLInputElement).value= "";
}
this.promptDialogLink.hide();
} |