Designer templates loading

Posted by: mateusz.jagodzinski on 1 February 2021, 2:20 am EST

    • Post Options:
    • Link

    Posted 1 February 2021, 2:20 am EST - Updated 3 October 2022, 12:53 am EST

    Hi

    I’m using spreadJS v14.0.6 with React component (@grapecity/spread-sheets-designer-react).

    With the designer templates feature it is possible to create designer templates, save them and then load them from file. https://www.grapecity.com/spreadjs/docs/v13/online/designertemplate.html

    What I would like to achieve is to load specific designer template schema on designer component initialization, so that user can work with already defined schema in the designer sidebar. (Desired action is equivalent to Load Schema action from the ribbon)

    Since I can’t find relevant documentation, can you please provide an example of how this could be achieved programmatically, or point me to relevant API docs?

    Best Regards,

    Mateusz

  • Posted 2 February 2021, 9:58 pm EST

    Hi,

    You may use setDataSource method for the required functionality. Please refer to the following code snippet and let us know if you face any issues.

    var spread  = designer.getWorkbook()
    var activeSheet = spread.getActiveSheet();
    
    var people = [
        {name: "Albert", isAdult: false, country: "American", website: "albert.com"},
        {name: "Alice", isAdult: true, country: "China", website: "alice.com"},
        {name: "Bob", isAdult: false, country: "Canada", website: "bob.com"}
    ];
    activeSheet.setDataSource(people);
    
    

    DataSource Demo: https://www.grapecity.com/spreadjs/demos/features/data-binding/sheet-level-binding

    Regards

    Avinash

  • Posted 15 March 2021, 11:55 pm EST - Updated 3 October 2022, 12:53 am EST

    Hi

    Thanks for the answer, but it did not help in my case.

    I know I can set data source to a sheet but that’s not what I’m trying to achieve. I want to set specific schema on a designer.

    This data also gets exported as designerBindingPathSchema when exporting workbook to .ssjson. But it does not appear when using workbook.toJson() method (even though the rest of the json is pretty similar). I tried manually adding it to the json before using fromJson() mtheod, but it also does not work.

    So, how could I add it programatically?

    Best Regards,

    Mateusz

  • Posted 16 March 2021, 5:07 pm EST

    Hi Mateusz,

    Thanks for the information, We were unable to achieve the required functionality using the current public API hence we have escalated this issue to the concerned team for further investigation. We will update you regarding this as soon as we get any information. The internal ID for this issue will be SJS-7997.

    Regards

    Avinash

  • Posted 26 March 2021, 11:16 pm EST

    Hi,

    The Devs informed us that the template tree trigger by a state called “treeNodeFromJson”

    So, if you would like to load a default template schema, you could apply the json schema to “treeNodeFromJSON” state then refresh the designer.

    Please refer to the following attached sample that demonstrated the same.

    Regards,

    Avinash

    demo.zip

Need extra support?

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

Learn More

Forum Channels