Ajax API

Code Effects comes with rich client functionality that can be used in client-centric web applications. Aside from the server-side code that helps it process business rules, the Rule Editor is written as a client-side class that encapsulates a lot of functionality, and expresses it through a relatively small number of public functions available to any other client code. Code Effects declares only two global (public) variables, $rule and $ce, and keeps everything else inside the scope of its instance. This makes it safe to add to any markup with any kind of client code.

Rule Editor is a self-contained library. Other than .NET and DOM, it doesn't depend on any client or server frameworks or libraries. It is compatible with all newer versions of all major browsers.

Global shortcuts

  • $ce Returns: Code Effects instance
    Parameters:
    • id, String - Server ID of the Code Effects.
    var codeeffects = $ce("RuleEditor1");
  • $rule Returns: CodeEffects.Rule namespace

    This shortcut is declared to make the markup footprint of Code Effects smaller. It is not intended for public use.

Public functions

  • clear() Returns: Code Effects instance
    Parameters: None

    Removes all elements of the current rule from the Rule Area.

  • deleted(String) Returns: Code Effects instance
    Parameters:
    • id, String - ID of the rule that is being deleted. Required.

    Calling this method after deleting a rule is necessary in order to remove this rule from the Rules and context menus. See the related demo for details on saving rules in an Ajax implementation.

  • extract() Returns: String
    Parameters: None

    Returns a JSON string that contains the current rule, and whether or not it’s valid. Returns an empty object if the Rule Area is empty. Use this method if you need to get the current rule in order to evaluate it in the browser. See the related demo for details on client-side rule evaluation.

  • isEvaluationType() Returns: Boolean
    Parameters: None

    Returns True if the loaded rule is of the evaluation type, or if the rule author selected the New evaluation type rule item from the Rules menu of the Toolbar. This method does not check what kind of rule elements the rule author has added to the Rule Area so far.

  • getRuleId() Returns: String
    Parameters: None

    Returns the string ID of the current rule assigned by Code Effects. Code Effects calls .NET's System.Guid.NewGuid().ToString() to get new IDs for rules. Returns null if no rules have been loaded into the Rule Editor yet, if Code Effects hasn't assigned an ID to the current rule yet, or if the Rule Editor is empty.

  • loadInvalids(String) Returns: Code Effects instance
    Parameters:
    • data, String - JSON string received from the server-side GetClientInvalidData() method of the RuleEditor class in ASP.NET or MVC. See the related demo for details on loading invalid rule data into the Rule Editor in an Ajax implementation. This is a required parameter.

    Call this function to load data of the invalid rule into the Rule Editor.

  • loadRule(String) Returns: Code Effects instance
    Parameters:
    • data, String - JSON string received from the server-side GetClientRuleData() method of the RuleEditor class in ASP.NET or MVC. See the related demo for details on loading rules into the Rule Editor in Ajax implementation. This is a required parameter.

    Call this function to load a rule into the Rule Editor.

  • loadSettings(String) Returns: Code Effects instance
    Parameters:
    • data, String - JSON string received from the server-side GetClientSettings() method of the RuleEditor class in ASP.NET or MVC. See the related demo for details on loading Code Effects client settings in Ajax implementation. This is a required parameter.

    Call this function to load Code Effects client settings. You also need to call this function every time the rule author requests a change in any of the Code Effects settings such as Help String visibility and so on.

  • saved(String) Returns: Code Effects instance
    Parameters:
    • id, String - ID of the rule that has been saved or updated. This parameter is required for new rules but optional for updates.

    Calling this method after saving a new rule or updating an existing one is necessary in order to refresh the Rules and context menus with the new or updated values. See the related demo for details on saving rules in an Ajax implementation.

  • setClientActions(Function, Function, Function) Returns: Code Effects instance
    Parameters:
    • loadRule, Function - callback that handles loading a rule. This callback function takes one parameter (String type). Code Effects calls this function and passes it the ID of the rule when rule author has selected that rule from the Toolbar's Rules menu. This is a required parameter.
    • deleteRule, Function - callback that handles deleting a rule. This callback function takes one parameter (String type). Code Effects calls this function and passes it the ID of the rule when the rule author has clicked the Delete button on the Toolbar. This is a required parameter.
    • saveRule, Function - callback that handles saving of a rule. This callback function takes one parameter (Object type). Code Effects calls this function and passes it an object that contains the rule data when the rule author has clicked the Save button on the Toolbar. This callback works in tandem with the LoadClientData() method of the RuleEditor class in ASP.NET or MVC. See the related demo for details on saving rules in an Ajax implementation. This parameter is required.

    Call this function while initializing your page to tell Code Effects which functions to call when the rule author wants to load, delete, or save a rule. Don't call it if Toolbar is disabled.

Post your support requests on Stackoverflow.com. You can also post your comments and product feedback using the form at the bottom of this page.
Comments: 0
Name (optional):
Comment (URLs are allowed and must start with http:// or https://; all tags will be encoded):
Remaining character count: