make user to enter the text of nodes at the time of dropping into the diagram space

Hi,
How can I make user to forcely enter the text on the node at the time of creating (that is when user select node from the pallate and drop on the diagram space), and without entering text into it the node should not be dropped into the diagram space.

13 Replies

SK Suganthi Karuppannan Syncfusion Team February 21, 2020 10:53 AM UTC

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.   
 
 
We have attached the sample for your reference.  Please refer to the sample in the below link. 
 
 
 
Regards,   
Suganthi K. 



RA RakhiS February 24, 2020 04:35 AM UTC

Thanks, it is working


RA RakhiS replied to Suganthi Karuppannan February 24, 2020 05:50 AM UTC

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.   
 
 
We have attached the sample for your reference.  Please refer to the sample in the below link. 
 
 
 
Regards,   
Suganthi K. 


Hi, it is working fine in case of nodes, and also I have applied in the same way in the connectors case. But When I am entering the text into its textbox, I want that it gets entered as the connectors text and show in the middle above the line of the connectors. Please help to achieve this



GG Gowtham Gunashekar Syncfusion Team February 24, 2020 10:42 AM UTC

Hi RakhiS, 
 
We have modified the sample to update the connector annotation while drag and drop the connector form symbol palette and we have attached the sample link below. 
 
 
Regards, 
Gowtham G 



RA RakhiS March 6, 2020 06:12 AM UTC

Hi,
I have created other dialogue that wil open at the time of link drop into the diagram space and the label which we provide will display on the link. For that this is my code, but here annotation[0] is showing undefined.
//-------------------------.ts file
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[0].content = this.connectorname; it is showing error "content of undefined"
          this.diagram.dataBind();
        }
      }
    }
    this.promptDialogLink.hide();
  }

//--------.html file
                [buttons]='promptDlgButtonsLinks'
                [visible]='hidden'
                [header]='promptHeader'
                [animationSettings]='animationSettings'
                [showCloseIcon]='showCloseIcon'
                [target]='target'
                (open)="dialogOpenLink()"
                (close)="dialogCloseLink()"
                isModal="true"
                [width]='promptWidth'>
    
     
       
         
           
           
         
       
Link Text:
             
               
                       id="annotationContentLink"
                       (focus)='onFocuslnk()' (blur)='onBlurlnk()' name="Required"
                       class="e-input" />
             
           
     
   


please help to resolve this


SG Shyam G Syncfusion Team March 9, 2020 05:29 AM UTC

Hi Rakhi, 
 
The reported issue occurs when you have not initialized the annotation for the symbols in the symbol palette. Either, you can define the annotation initially for the symbols in the symbol palette or you can initialize it at runtime. We have modified your code example in which we have initialized the annotation at runtime to resolve your issue. Please refer to a modified code example below. 
 
Code example: 
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(); 
  } 
 
 
 
Regards, 
Shyam G 



RA RakhiS March 9, 2020 08:16 AM UTC

Hi, I tried the modified code, but it not working.
Please help!




SG Shyam G Syncfusion Team March 10, 2020 07:14 AM UTC

Hi Rakhi, 

As mentioned earlier, the reported issue occurs when the annotation collection is not initialized at code behind. We have created a sample in which we have initialized annotation collection at symbol palette getNodeDefaults and getConnectorDefaults method. Please refer to a code example and the sample below. Still if you face any problem, please share us more details such as modify the below sample. 

Code example: 
<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 = []; 
    }  



Regards, 
Shyam G 



RA RakhiS March 13, 2020 05:38 AM UTC

Hi below is my all code in detail. my problem is just after this code
This is the dialog which gets open when a link(connector) drop into the diagram space.
---------------------------------------------------------------------
step 2:


step3


step4


step5:


step6


Step7



------------------------------------------------------------------------------------------

step 8



Problem:

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 help

Thanks


RA RakhiS replied to RakhiS March 16, 2020 07:23 AM UTC

Hi below is my all code in detail. my problem is just after this code
This is the dialog which gets open when a link(connector) drop into the diagram space.
---------------------------------------------------------------------
step 2:


step3


step4


step5:


step6


Step7



------------------------------------------------------------------------------------------

step 8



Problem:

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 help

Thanks

Please reply, as it is on the higher priority. I want to show two different dialogues and on supplying name it should add the name on the respective item. I am getting error native element of undefined.


SG Shyam G Syncfusion Team March 16, 2020 11:00 AM UTC

Hi Rakhi, 
 
We have created a sample with your code example and fixed the issues in your application. Please find the changes highlighted in the below code example. 
 
Code example: 
<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(); 
    } 
 
 

Regards, 
Shyam G 



RA RakhiS March 17, 2020 04:31 AM UTC

Thankyou so much, working


SG Shyam G Syncfusion Team March 17, 2020 04:35 AM UTC

Hi Rakhi, 
Thanks for your update. 
Regards, 
Shyam G 


Loader.
Up arrow icon