Pallete OnClick event - Get clicked node reference

How can we get a reference to the just clicked node inside a pallete? I am not looking for the node inside the diagram. 

<SfSymbolPalette @onclick="@OnClickPallete" EnableAnimation="true" SymbolInfo="@symbolInfo" ExpandMode="ExpandMode.Multiple" @ref="@SymbolPalette" Palettes="@Palettes">
 </SfSymbolPalette>

public void OnClickPallete(MouseEventArgs args)
{
     // Need reference here
     DiagramNode nodeSelected = SymbolPalette.SelectedNode;
     DiagramConnector connecterSelected = SymbolPalette.SelectedConnector;
}

6 Replies 1 reply marked as answer

AR Aravind Ravi Syncfusion Team September 7, 2020 05:45 AM UTC

Hi Scott, 
 
We have created a sample to get the symbol Id and symbol reference in the palette selection event. When you select a symbol in the symbol palette, OnPaletteSelectionChange event gets triggered. In that event through args NewValue you can get the symbol id. Through that symbol id , iterate the all symbols in palette and get the respective symbol reference and its shape type through its ID. Please find the below code snippet for how to get element shape type using OnPaletteSelectionChange event  
  
<SfSymbolPalette @ref="palette" id="palettes" Width="100%" Height="700px" ExpandMode="Syncfusion.Blazor.Navigations.ExpandMode.Multiple" SymbolWidth="60" SymbolHeight="60" Palettes="@Palettes">  
  
            <SymbolMargin Left="12" Right="12" Bottom="12" Top="12"></SymbolMargin>  
            <SymbolPaletteEvents OnPaletteSelectionChange="PaletteSelectionChange"></SymbolPaletteEvents>  
        </SfSymbolPalette>  
  
  
public void PaletteSelectionChange(IPaletteSelectionChangeArgs args)  
     
        if(args.NewValue != null)  
         
            for (int i = 0; i < palette.Palettes.Count; i++)  
             
                for (int j = 0; j < palette.Palettes[i].Symbols.Count; j++)  
                 
                    if(args.NewValue == (palette.Palettes[i].Symbols[j] as DiagramNode).Id )  
                     
                        Console.WriteLine((palette.Palettes[i].Symbols[j] as DiagramNode).Shape.Type);  
                        Console.WriteLine((palette.Palettes[i].Symbols[j] as DiagramNode)); 
                     
                 
             
         
     
  
 
We have attached a sample for your reference. Please find the sample in below link 
 
 
Regards 
Aravind Ravi 


Marked as answer

SP Scott Peal September 7, 2020 02:31 PM UTC

Awesome!

Please consider adding this to the documentation under events.


AR Aravind Ravi Syncfusion Team September 8, 2020 04:23 AM UTC

Hi Scott, 
 
We have documentation for the native events but does not have for the Events. We have already logged a documentation improvement task to add event documentation for Diagram components. We will include the documentation on or before the 2020 Volume 3 2020 SP1 release. We will let you know once the documentation gets published in live.   
 
Regards 
Aravind Ravi 



AR Aravind Ravi Syncfusion Team November 10, 2020 04:15 AM UTC

Hi Scott,   
   
Sorry for the inconvenience caused. We are unable to publish the publish the documentation in this release. We will include the documentation on or before the 2020 Volume 4 release. We will let you know once the documentation gets published in live.     
   
Regards   
Aravind Ravi   



AR Aravind Ravi Syncfusion Team December 21, 2020 09:00 AM UTC

Hi Scott,  
  
Sorry for the inconvenience caused.  Due to complexity of the requirement, we are unable to publish the publish the documentation in this release. We will include the documentation on or before the 2021 Volume 1 release. We will let you know once the documentation gets published in live. 
  
Regards  
Aravind Ravi 



GG Gowtham Gunashekar Syncfusion Team April 1, 2021 05:51 AM UTC

Hi Scott,   

Thanks for your patience .Our volume 1 2021,release has been rolled out successfully and we have included the documentation changes in the release. The documentation has been refreshed and published in live. Please refer to the below updated link  
  
  
Regards   
Gowtham  



Loader.
Up arrow icon