Available in the OSS Version

Combo Box - XML Binding

This sample is designed for a larger screen size.

On mobile, try rotating your screen, view full size, or email to another device.

The combo supports binding to XML data. This sample shows a basic example of binding to an XML string.

Code View

Copy to Clipboard
<!DOCTYPE html>
<html>
<head>
    <title></title>

    <!-- Ignite UI for jQuery Required Combined CSS Files -->
    <link href="http://cdn-na.infragistics.com/igniteui/2024.2/latest/css/themes/infragistics/infragistics.theme.css" rel="stylesheet" />
    <link href="http://cdn-na.infragistics.com/igniteui/2024.2/latest/css/structure/infragistics.css" rel="stylesheet" />

    <script src="http://ajax.aspnetcdn.com/ajax/modernizr/modernizr-2.8.3.js"></script>
    <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
    <script src="http://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>

    <!-- Ignite UI for jQuery Required Combined JavaScript Files -->
    <script src="http://cdn-na.infragistics.com/igniteui/2024.2/latest/js/infragistics.core.js"></script>
    <script src="http://cdn-na.infragistics.com/igniteui/2024.2/latest/js/infragistics.lob.js"></script>

</head>
<body>

    <div id="combo"></div>

    <script>
        $(function () {
                        
            //Sample XML Data
            var xmlDoc = '<People>' +
                '<Person ID="1" Name="Gustavo Achong" />' +
                '<Person ID="2" Name="Catherine Abel" />' +
                '<Person ID="3" Name="Kim Abercrombie" />' +
            '</People>';

            //Binding to XML requires a schema to define data fields
            var xmlSchema = new $.ig.DataSchema("xml",
                { 
                    //searchField serves as the base node(s) for the XPaths
                    searchField: "//Person", 
                    fields: [
                        { name: "ID", xpath: "./@ID" },
                        { name: "Name", xpath: "./@Name" }
                    ]
                }
            );

            //This creates an Infragistics datasource from the XML 
            //and the Schema which can be consumed by the grid.
            var ds = new $.ig.DataSource({
                type: "xml",
                dataSource: xmlDoc,
                schema: xmlSchema 
            });

            $("#combo").igCombo({
                dataSource: ds, //$.ig.DataSource defined above
                valueKey: "ID",
                textKey: "Name"
            });

        });

    </script>

</body>
</html>