Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Accessing TabbedDiagramView in React (Read 54 times)
Kamil
YaBB Newbies
*
Offline



Posts: 22
Joined: Aug 22nd, 2024
Accessing TabbedDiagramView in React
Dec 30th, 2024 at 1:22pm
Print Post  
Hi Smiley Our react application uses tabbed diagram view. We get that view by using mfDiagramming.DiagramView.find. The returned object is DiagramView type (not TabbedDiagramView). So, we had to create a type along with its typeguard and use them every time we want to access document, selectedIndex & selectedPage properties:

Code (Javascript)
Select All
export type TTabbedDiagram = {
    document: mfDiagramming.DiagramDocument;
    selectedPage: mfDiagramming.DiagramPage;
    selectedIndex: number;
};

export const isTabbedDiagram = (obj: unknown): obj is TTabbedDiagram => {
    const _obj = obj as TTabbedDiagram;
    return (
        _obj?.document !== undefined &&
        _obj?.selectedPage !== undefined &&
        _obj?.selectedIndex !== undefined
    );
};


const _diagramView = mfDiagramming.DiagramView.find(DIAGRAM_VIEW_ID);
const diagramView = isTabbedDiagram(_diagramView) ? _diagramView : null;
 



Is there a better way to get TabbedDiagramView object? Something like: mfDiagramming.TabbedDiagramView.find method.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3321
Joined: Oct 19th, 2005
Re: Accessing TabbedDiagramView in React
Reply #1 - Jan 3rd, 2025 at 7:51am
Print Post  
Hi,

We'll add it to tabbed view for next week's release. You could also try using type assertion at this time:

Code
Select All
import * as Diagramming from '@mindfusion/diagramming';
import * as DControls from '@mindfusion/diagramming-controls';

const _diagramView = (Diagramming.DiagramView.find(DIAGRAM_VIEW_ID) as DControls.TabbedDiagramView); 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Kamil
YaBB Newbies
*
Offline



Posts: 22
Joined: Aug 22nd, 2024
Re: Accessing TabbedDiagramView in React
Reply #2 - Jan 3rd, 2025 at 10:38am
Print Post  
Ok, thank you Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint