Jump to content
We've recently updated our Privacy Statement, available here ×
  • Visualize.js - API Notes and Samples - Input Controls


    nesterone

    API Reference

    Properties

    InputControls Properties Schema

    {
        "type": "object",
        "properties": {
            "server": {
                "type": "string",
                "description": "Url to JRS instance."
            },
            "resource": {
                "type": "string",
                "description": "URI of resource with input controls.",
                "pattern": "^/\\w*(/\\w+)*$"
            },
            "params": {
                "type": "object",
                "description": "Parameters for input controls.",
                "additionalProperties": {
                    "type": "array"
                }
            }
        },
        "required": ["server", "resource"]
    }
    

    Data

    InputControls data() is an array of InputControl objects:

    [
      {
        "id":"Cascading_name_single_select",
        "label":"Cascading name single select",
        "mandatory":"true",
        "readOnly":"false",
        "type":"singleSelect",
        "uri":"repo:/reports/samples/Cascading_multi_select_report_files/Cascading_name_single_select",
        "visible":"true",
        "masterDependencies": {
          "controlId": [
            "Country_multi_select",
            "Cascading_state_multi_select"
          ]
        },
        "slaveDependencies":null,  
        "validationRules": [
          {
            "mandatoryValidationRule" : {
              "errorMessage" : "This field is mandatory so you must enter data."
            }
          }
        ],
        "state": {
          "uri": "/reports/samples/Cascading_multi_select_report_files/Cascading_name_single_select",
          "id": "Cascading_name_single_select",
          "value": null,
          "options": [
            {
              "selected": false,
              "label": "A & U Jaramillo Telecommunications, Inc",
              "value": "A & U Jaramillo Telecommunications, Inc"
            }
          ]
        }             
      },
      ....
    ]
    

    For more details see Cascading#GetinitialstructureofInputControls.

    InputControls

    /**
    * Constructor. Takes properties as argument.
    * @param properties - map of properties.   
    */
    function InputControls(properties){};
    /**
    * Get/Set 'resource' property - URI of resource with input controls.
    * @param value - new value, optional
    * @returns this if 'value' sent to the method,
    *          otherwise returns current value of the parameter
    */
    InputControls.prototype.resource = function(value){};
    /**
    * Get/Set 'params' property - Parameters for input controls.
    * @param value - new value, optional
    * @returns this if 'value' sent to the method,
    *          otherwise returns current value of the parameter
    */
    InputControls.prototype.params = function(value){};
    

    Workflows

    Make simple call to server

    (new InputControls({
        server: ",
        resource: "/public/my_report",
        params: {
            "Country_multi_select":["Mexico"],
            "Cascading_state_multi_select":["Guerrero", "Sinaloa"]
        }
    })).run(function(inputControlsArray){
        // results here
    })
    

    Reuse instance to make close calls

    var inputControls = new InputControls({
        server: ",
        resource: "/public/my_report"
    });
    
    ......
    // call 1
    inputControls.params({ "Country_multi_select": ["Mexico"] }).run(doSomethingWithResultFunction);
    
    ......
    // call 2 after some time
    inputControls.params({ "Country_multi_select": ["USA"] }).run(doSomethingWithResultFunction);
    

    Reuse results later

    var call = (new InputControls({
        server: ",
        resource: "/public/my_report"
    })).run(function(inputControlsArray){
        // results here, data() available, i.e it this point call.data() === inputControlsArray -> true
    });
    
    // at this point call.data() will return null until the run callback will be called. 
    call.data() === null // -> true
    
    .....
    // if some data was obtained earlier, it accessible via data()
    var inputControlsArray = call.data();
    

    Validate set properties without actual call

    var ic = new InputControls({
        server: ",
        resource: "/public/my_report",
        params: {
            "Country_multi_select":["Mexico"],
            "Cascading_state_multi_select":["Guerrero", "Sinaloa"]
        }
    });
    
    var error = ic.validate();
    
    if (!error){
        // valid
    } else {
        // invalid, read details from error
    }
    

    <>

     


    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...