Dynamically Creating Data Sets

Posted by: katie.koslosky on 13 September 2021, 2:25 am EST

    • Post Options:
    • Link

    Posted 13 September 2021, 2:25 am EST

    “Using pre-defined data sources” overviews the process of creating pre-defined datasources & datatemplates using the Designer Desktop App. https://www.grapecity.com/activereportsjs/docs/DeveloperGuide/ActiveReportsJSDesignerComponent/Add-Predefined-Datasources-Datasets

    Is there a way to do this dynamically & programmatically in our JavaScript application?

    I can add the Data Source Connection Properties, but I’m hoping there is a way to programmatically call the 'Validate" functionality for a given Path in order to set dataset information without user intervention.

                    
    ref.current.setReport({ 
                        definition: {
                            ...report.definition,
                            DataSources: [{
                                Name: "Data",
                                ConnectionProperties:{
                                    DataProvider: "JSONEMBED",
                                    ConnectString: "jsondata=" + JSON.stringify(data),
                                }
                            }]
                        }
                    });
    
    
  • Posted 16 September 2021, 1:42 am EST

    Actually, I’m more or less successfully doing this. The only thing I would like to know at this point is if there is a way to make the dataset uneditable when opening them this way

    
        React.useEffect(()=>{
            if(data != null){
                console.log("data", data);
                console.log("data[0]", data[0]);
                console.log("JSON.stringify(data)", JSON.stringify(data));
                ref.current.getReport().then((report: ReportInfo) =>{
                    const keys = Object.keys(data[0]);
                    const fields = keys.map(key => ({
                        "Name": key,
                        "DataField": key 
                    }));
                    ref.current.setReport({ 
                        definition: {
                            ...report.definition,
                            DataSources: [{
                                Name: "Data",
                                ConnectionProperties:{
                                    DataProvider: "JSONEMBED",
                                    ConnectString: "jsondata=" + JSON.stringify(data),
                                },
                            }],
                            DataSets: [{
                                Name: "DataSet",
                                Query: {
                                    CommandText: "jpath=$.*",
                                    DataSourceName: "Data"
                                },
                                Fields: fields,
                                AccentSensitivity: "Auto",
                                CaseSensitivity: "Auto",
                                KanatypeSensitivity: "Auto",
                                WidthSensitivity: "Auto",
                            }]
                        }
                    });
                    setLoading(false);
                })
    
            }
        },[data]);
    
    
  • Posted 20 September 2021, 7:35 pm EST

    Pre-defined data sets can be uneditable, but the code you shared sets the connection properties directly.

    The only way to make a data set uneditable for now is to hide the “Edit” button by using the corresponding CSS selector - you can inspect the designer UI in the browser and find it out.

Need extra support?

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

Learn More

Forum Channels