Articles in this section

How to Automatically Update Dataset Names from Shared Dataset Selection in Bold Reports Designer

Published:
Updated:

This article explains how to automatically update the dataset name field to match the selected shared dataset’s name in Bold Reports Designer. This approach helps maintain naming consistency and avoids confusion caused by default generic dataset names in complex reporting projects.

By default, the Bold Reports Web Designer assigns a generic name such as DataSet1 when a shared dataset is selected. Manually renaming datasets each time can be time-consuming. By adding a small JavaScript snippet, you can automatically synchronize the dataset name field with the selected shared dataset name immediately after selection.

Step-by-Step Instructions

Step 1. Configure the ajaxSuccess event

  • Locate your designer initialization script and add the ajaxSuccess property. Assign it to a callback function such as sharedDatasetName.
    $("#designer").boldReportDesigner({
        ajaxSuccess: sharedDatasetName
    });
    

Step 2. Implement the callback function

  • Add the following JavaScript function to your script block. This function detects when the shared dataset catalog loads and binds a selection event to the dropdown.
    function sharedDatasetName(args) {
        // Check if the AJAX request is for loading the Shared Dataset Catalog
        if (args.actionType == 'DataSetCatalog') {
            // Retrieve the Syncfusion EJ2 instance of the shared dataset dropdown
            var dropdownElement = $('#designer_shared_data_drdwn')[0].ej2_instances[0];
            
            // Bind the select event to update the name field automatically
            dropdownElement.select = (args) => {
                var nameTextField = $('#designer_shared_txt')[0].ej2_instances[0];
                nameTextField.value = args.itemData.Name;
            };
        }
    }
    

Step 3. Save and test the changes

Save your changes and refresh the designer in your browser.

  1. Open the Data panel.
  2. Select a shared dataset from the dropdown list. The dataset name field will now automatically update to match the selected shared dataset name.

Code Breakdown

Code Snippet Explanation
ajaxSuccess: sharedDatasetName Calls the custom function whenever an AJAX request completes successfully in the designer.
args.actionType == 'DataSetCatalog' Ensures the logic runs only when the shared dataset list is loaded.
$('#designer_shared_data_drdwn') Target ID for the shared dataset dropdown component in the designer UI.
args.itemData.Name Retrieves the actual name of the shared dataset selected by the user.
$('#designer_shared_txt') Target ID for the text input field where the dataset name is stored.

Step 4 Preview

1. Before Code Implementation
  • The dataset name field remains generic (e.g., DataSet1) and does not change when a shared dataset is selected.
    before.gif
2. After code Implementation
  • The dataset name field automatically synchronizes with the selected shared dataset’s name immediately upon selection.
    after.gif

Download the sample application here

See Also

Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied