WjGroupPanel in a component with a Template Literal

Posted by: rbutler on 24 November 2018, 1:44 am EST

    • Post Options:
    • Link

    Posted 24 November 2018, 1:44 am EST

    Hi,

    As the title says, I am attempting to use the wijmo vue2 control, WjGroupPanel with the WjFlexGrid.

    • My Flexgrid is defined as a template component using a template literal.
    • This component tag is inside another template literal for a layout component.

    I have added the wj-group-panel markup to the same layout component but that doesn’t appear to be working.

    Could you show me an example of the wijmo grid and the group panel as nested components in a template literal?

  • Posted 26 November 2018, 12:11 am EST

    Please refer to the following sample:

    https://codesandbox.io/s/8xy5r8yxl0

    Please let us know if you still face any issues.

    ~Sharad

  • Posted 26 November 2018, 12:28 pm EST

    Hi Sharad,

    Thank you for the response. Actually, this example uses inline templates instead of template literals.

    An inline template looks like this

    Whereas a template literal can specified in a vue component instantiation. My code is like this:

    
    Vue.Component("my-component", 
    {
    props: {...},
    methods:{...},
    template: 
    `<tag>
    ...
    <div><wj-group-panel id="thePanel"></wj-group-panel></div>
    
    <my-grid id="theGrid"></my-grid>
    ...
    
    </tag>`
    });
    
    
    Vue.Component("my-grid", 
    {
    props: {...},
    methods:{...},
    template: 
    `<wj-flex-grid>
    ...
    </wj-flex-grid>`
    });
    

    Note the backticks to delineate the literal. This is something called a Template Literal (introduced in ES6). It just lets you have a multi-line string.

    Also note, I’ve tried placing the ID attribute on both the component and alternately on the grid tag itself.

    I placed the binding code in the mounted event handler of the root Vue and while it can find the elements of the panel and the grid, neither of these elements are recognized by Wijmo as a control in the getControl() call:

    wijmo.Control.getControl(document.getElementById('thePanel')); // RETURNS NULL
    

    Internally, this call makes a call to wijmo.getElement(), which returns an object. But the next call fails because the object does not have this property defined: CTRL_KEY_

    I mocked this code in my own script and tried setting that property on the object but learned that this is not a persistent object and is created new each time getElement() is called.

    When I worked around that, I learned that additional properties are not present.

    This isn’t surprising as I think some initialization step is not occurring to make the elements true wijmo controls before they are mounted in the DOM.

  • Posted 26 November 2018, 2:02 pm EST

    I should add, the grid otherwise works fine, so the control is at some point created correctly. I suspect this may be a timing issue - or that an internal exception in the wijmo API is short-circuiting something (possibly because I’m placing the code in the wrong handler).

  • Posted 27 November 2018, 1:23 am EST

    Inline templates or template literals both are different ways to define templates so IMHO it should not affect the application.

    Please refer to the following sample which adds components using Vue.component() method and template literals:

    https://codesandbox.io/s/n99onz9ly0

    Key things to observe:

    • Within my-grid component, FlexGrid instance is attached to the component instance using control attribute.

    <wj-flex-grid :items-source=“data” control=“grid” id=“theGrid” :initialized=“initGrid”>



    • Within ‘my-component’ component’s mounted hook, ‘my-grid’ component’s instance is accessed using $refs and then FlexGrid’s instance is assigned to groupPanel.grid.

    ~Sharad

  • Posted 27 November 2018, 4:03 pm EST

    Thanks, Sharad, this helped immensely.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels