JSON Data Format

All WebService enabled controls (WSDropDown, WSContextMenu, WSTreeView, WSListView) uses the JSON data format. JSON is an industry standard for data interchange. More information about JSON is available on http://json.org.
Example data
[
    {
        Title: "JavaScript UI frameworks",
        Value: "1001",
        Selectable: false,
        Children:
        [
            {
                Title: "Jquery UI",
                Value: "jqui",
                Selectable: true
            },
            {
                Title: "Fit.UI",
                Value: "fitui",
                Selectable: true
            },
            { ... }, { ... }
        ]
    },
    {
        Title: "More frameworks",
        Value: "1002",
        Selectable: false,
        HasChildren: true
    },
    { ... }, { ... }
]

Properties
Value:string
Required - this property MUST be defined AND be unique.
Title:string
Optional - this value will be used as the display value. Value will be used if Title is not defined.
Selectable:boolean
Optional - this value determines whether item can be selected. The value is considered True if not defined.
Children:array
Optional - this property contains any children in the same format as root nodes.
HasChildren:boolean
Optional - a value of True causes WSTreeView and WSDropDown to load children when needed. This is useful for very large amounts of data.

HasChildren
To support the use of HasChildren the developer is reponsible for enriching requests to the server with information about the parent node for which children is requested. The code below demonstrates this, and works for instances of both WSDropDown and WSTreeView.
myControl.OnRequest(function(sender, args)
{
     // Node is not set when requesting root nodes
    var nodeValue = (args.Node ? args.Node.Value() : "");

    if (Fit.Core.InstanceOf(args.Request, Fit.Http.JsonpRequest))
    {
        // Add parent node value to JSONP request.
        // Value is now accessible server side from GET data.
        args.Request.SetParameter("ParentNode", nodeValue);
    }
    else if (Fit.Core.InstanceOf(args.Request, Fit.Http.JsonRequest))
    {
        // Add parent node value to ordinary JSON request.
        // Value is now accessible server side from POST data.
        args.Request.SetData({ParentNode: nodeValue});
    }
});
 
Fit.UI is open source (LGPL) - download or fork it on GitHub - website powered by Sitemagic CMS