Custom Data Source

Stimulsoft Reports.JS discussion
Post Reply
jclPTSG
Posts: 6
Joined: Fri Mar 02, 2018 1:00 pm

Custom Data Source

Post by jclPTSG »

Is there a way to remove the Current Data sources and Create a Custom one.

My clients don't know SQL and they would be confused with all the choices.

I would like to create my on GUI for a datasource.

thank you!
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Custom Data Source

Post by Alex K. »

Hello,

Please try to check the following code:

Code: Select all

<body>
    <form id="form1" runat="server">
        <cc3:StiWebDesigner runat="server"
            ID="StiWebDesigner1" Localization="en.xml"
            OnGetReport="StiWebDesigner1_GetReport"
            OnCreateReport="StiWebDesigner1_CreateReport"
            OnOpenReport="StiWebDesigner1_OpenReport"
            OnPreviewReport="StiWebDesigner1_PreviewReport"
            OnExit="StiWebDesigner1_Exit" />
    </form>
    <script type="text/javascript">
        // where jsStiWebDesigner1 - "js" + Designer Id

        //Override Dictionary NewItem Menu
        var dictionaryNewItemMenu = jsStiWebDesigner1.options.menus.dictionaryNewItemMenu || jsStiWebDesigner1.InitializeDictionaryNewItemMenu();
        dictionaryNewItemMenu.oldAction = dictionaryNewItemMenu.action;

        dictionaryNewItemMenu.action = function (menuItem) {
            this.changeVisibleState(false);

            if (menuItem.key == "dataSourceNew") {
                //write your code here
                alert("New DataSource was clicked!")
            }
            else {
                dictionaryNewItemMenu.oldAction(menuItem);
            }
        }

        //Override Dictionary ContextMenu
        var dictionaryContextMenu = jsStiWebDesigner1.options.menus.dictionaryContextMenu || jsStiWebDesigner1.InitializeDictionaryContextMenu();
        dictionaryContextMenu.oldAction = dictionaryContextMenu.action;

        dictionaryContextMenu.action = function (menuItem) {
            this.changeVisibleState(false);

            if (menuItem.key == "dataSourceNew") {
                //write your code here
                alert("New DataSource was clicked!")
            }
            else {
                dictionaryContextMenu.oldAction(menuItem);
            }
        }
    </script>
</body>
Thank you.
jclPTSG
Posts: 6
Joined: Fri Mar 02, 2018 1:00 pm

Re: Custom Data Source

Post by jclPTSG »

Thank you for that.

I did have to modify the code that you sent. (had to add jsObject to the lines below.)

Updated code below:

Code: Select all

		var designer = new Stimulsoft.Designer.StiDesigner();
		
        var dictionaryNewItemMenu = designer.jsObject.options.menus.dictionaryNewItemMenu || designer.jsObject.InitializeDictionaryNewItemMenu();
        dictionaryNewItemMenu.oldAction = dictionaryNewItemMenu.action;

        dictionaryNewItemMenu.action = function (menuItem) {
            this.changeVisibleState(false);

            if (menuItem.key == "dataSourceNew") {
                //write your code here
                alert("New DataSource was clicked!")
            }
            else {
                dictionaryNewItemMenu.oldAction(menuItem);
            }
        }

        //Override Dictionary ContextMenu
        var dictionaryContextMenu = designer.jsObject.options.menus.dictionaryContextMenu || designer.jsObject.InitializeDictionaryContextMenu();
        dictionaryContextMenu.oldAction = dictionaryContextMenu.action;

        dictionaryContextMenu.action = function (menuItem) {
            this.changeVisibleState(false);

            if (menuItem.key == "dataSourceNew") {
                //write your code here
                alert("New DataSource was clicked!")
            }
            else {
                dictionaryContextMenu.oldAction(menuItem);
            }
        }


Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Custom Data Source

Post by Alex K. »

Hello

We are always glad to help you!
Please let us know if you need any additional help.

Thank you.
Post Reply