製品版のみの機能
階層グリッド - XML のバインド
このサンプルは CTP 機能を使用しています。製品版では、API や動作が変更される場合があります。
このサンプルは、より大きい画面サイズのためにデザインされました。
モバイル デバイスで画面を回転、フル サイズ表示、またはその他のデバイスにメールで送信します。
このサンプルでは、igHierarchicalGrid コントロールを XML データ ソースにバインドする方法を紹介します。注: XML へのバインドは、データ フィールドを定義するスキーマが必要です。
コード ビュー
クリップボードへコピー
<!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>
<table id="hierarchicalGrid1"></table>
<script>
$(function () {
//Sample XML Data
var xmlDoc = '<OrgChart Name="全従業員">' +
'<Employee Name="Gustavo Achong" Age="42" Email="gachong@adventureworks.com">' +
'<Employee Name="Kim Abercrombie" Age="33" Email="kabercrombie@adventureworks.com" />' +
'<Employee Name="Lawrence Tapley" Age="52" Email="ltapley@adventureworks.com" />' +
'</Employee>' +
'<Employee Name="Catherine Abel" Age="27" Email="cabel@adventureworks.com">' +
'<Employee Name="Kristen Anderson" Age="30" Email="kanderson@adventureworks.com" />' +
'<Employee Name="Richard Lee" Age="25" Email="rlee@adventureworks.com" />' +
'<Employee Name="Victoria Gramley" Age="23" Email="vgramley@adventureworks.com" />' +
'</Employee>' +
'<Employee Name="Adrienne Mauro" Age="27" Email="amauro@adventureworks.com">' +
'<Employee Name="Christopher Chadwick" Age="37" Email="cchadwick@adventureworks.com" />' +
'</Employee>' +
'</OrgChart>';
//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: "OrgChart",
childDataProperty: "Employee",
fields: [
{ name: "Name", xpath: "@Name" },
{ name: "Age", xpath: "@Age" },
{ name: "Email", xpath: "@Email" },
{ name: "Employee", xpath: "Employee" }
]
}
);
//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
});
$("#hierarchicalGrid1").igHierarchicalGrid({
dataSource: ds, //$.ig.DataSource object defined above
autoGenerateColumns: false,
columns: [
{ headerText: "名前", key: "Name" }
],
columnLayouts : [{
key: "Employee",
autoGenerateColumns: false,
columns: [
{ headerText: "名前", key: "Name" },
{ headerText: "年齢", key: "Age" },
{ headerText: "メール", key: "Email" }
],
columnLayouts : [{
key: "Employee",
autoGenerateColumns: false,
columns: [
{ headerText: "名前", key: "Name" },
{ headerText: "年齢", key: "Age" },
{ headerText: "メール", key: "Email" }
]
}],
}]
});
});
</script>
</body>
</html>