We have updated Flexmonster Software License Agreement, effective as of September 30, 2024. Learn more about what’s changed.

C# reference custom API data source

Answered
Vera Didenko Vera Didenko asked on April 14, 2020

Hello, Jon,

This is a continuation of our previous communication.

Thank you for your detailed response.

Please see our recommendations and answers below:

  1. About handling permissioned data: 
    We kindly suggest the custom callback function approach described in the previous email. 
    The callback function provides the possibility to add custom response handling logic.
    This way you could control data access based on the logged-in user. 

  2. As for tracking the dataset version and refreshing the data without changing the view settings:
    This can be achieved by using the custom callback function approach described in the previous email.
    The general idea lies in passing the latest dataset version to the client in the response and keeping the dataset version used by the client on the client-side. Then with each new response, the versions can be compared and if the dataset got updated, a data refresh could be initiated.
    The updateData() API call can be used to refresh the data in Flexmonster without clearing the user's current view settings.

    Here is a code snippet for illustration:

    var pivot = new Flexmonster({
    container: "#pivot",
    height: 600,
    toolbar: true,
    report: {
    "dataSource": {
    "type": "api",
    "url": callbackFunction,
    "index": "fm-product-sales"
    },
    ...

    }
    ...
    });


    //The client's dataset version
    var datasetVersion = "";


    function callbackFunction(request, successCallback, errorCallback) {

    console.log("request >>> ;", request);

    // add further logic here (for example, get the response from the server)

    // refresh the data if the dataset version is outdated
    if (datasetVersion != "" && datasetVersion != response.datasetVersion) {

    datasetVersion = response.datasetVersion;
    pivot.updateData({
    "type": "api",
    "url": callbackFunction,
    "index": "fm-product-sales"
    });

    } else if (datasetVersion == "") {
    datasetVersion = response.datasetVersion;
    }

    successCallback(response.response);
    }

    This way it is possible to track the dataset version used by the client and update it when needed.

  3. About report management:
    Flexmonster provides the possibility to set default report settings, specifying the way the data will be initially displayed.
    This way you can provide the desired starting points for the reports.
    The users can then further configure the reports through the UI.
    For more information about configuring the report, please see: https://www.flexmonster.com/doc/available-tutorials-report/

    These reports can then be saved locally or to a remote data storage and loaded again later to view or continue working on them. 
    The reports can be saved either through the Save Toolbar Tab or by using the save() API call:

    The previously saved reports can be loaded in the following ways:
    3.1) Using the load() API call
    3.2) Using the setReport() API call

  4. As for further customization options:
    We would like to explain that in addition to the customization options that are available through the UI, Flexmonster provides a wide variety of configuration options, events and API calls that can be used to further customize the component.
    In addition, you can customize the Toolbar and context menu to add new tabs and options to the UI. 

    Here are the corresponding guides for more information:
    4.1) The list of Flexmonster API
    4.2) Customizing the Toolbar
    4.3) Customizing the context menu

    For example, the desired formatting that you describe can be achieved with the customizeCell() API call.
    Here is a JSFiddle example showing how negative numbers can be formatted in parens using customizeCell: https://jsfiddle.net/flexmonster/yp9ke1vu/

  5. Regarding the c# sample server:
    You are welcome to use it and customize it as needed. Our team is working on its further improvement and development, so it is being tested regularly.

 
Please let us know if this helps.
As always, please feel free to reach out to us in case of questions.
 
Kind regards,
Vera

1 answer

Public
Mykhailo Halaida Mykhailo Halaida Flexmonster May 19, 2020

Hi Jon,
 
We are happy to let you know that new negativeNumberFormat formatting property was added.
 
This is provided in the 2.8.7 version of Flexmonster: https://www.flexmonster.com/release-notes/
You are welcome to update the component. Here is our updating to the latest version guide for assistance: https://www.flexmonster.com/doc/updating-to-the-latest-version/ 
 
Please let us know if everything works fine for you.
 
Best regards,
Mykhailo

Please login or Register to Submit Answer