LIDOR SYSTEMS

Advanced User Interface Controls and Components

IntegralUI Web

Native Angular 4 and AngularJS UI Components


TreeGrid / Remote Data




In this sample we are using a remote JSON file as our data source to load the content of the TreeGrid. This file is large in size, approximately 14 MB, and becuase of this we can't display its content here. But you can access it from this link: JSON file.

This file contains 25 columns and 10,000 rows, and whenever the Load Remote button is clicked, its content is loaded into the TreeGrid using the AngularJS $http service and TreeGrid loadData method. By using this method you can change the content of the TreeGrid dynamically, in whole or to a specified row.

<!DOCTYPE html>

<html>

<head>

<link rel="stylesheet" href="css/integralui.css" />

<link rel="stylesheet" href="css/integralui.checkbox.css" />

<link rel="stylesheet" href="css/integralui.treegrid.css" />

<link rel="stylesheet" href="css/themes/theme-flat-blue.css" />

<script type="text/javascript" src="external/angular.min.js"></script>

<script type="text/javascript" src="js/angular.integralui.min.js"></script>

<script type="text/javascript" src="js/angular.integralui.lists.min.js"></script>

<script type="text/javascript" src="js/angular.integralui.checkbox.min.js"></script>

<script type="text/javascript" src="js/angular.integralui.treegrid.min.js"></script>

</head>

<body>

<div ng-app="appModule" ng-controller="appCtrl">

<iui-treegrid name="{{gridName}}" columns="columns" rows="rows" expanding-column-index="1" show-footer="false"></iui-treegrid>

</div>

</body>

</html>

angular

.module("appModule", ["integralui"])

.controller("appCtrl", ["$scope", "IntegralUITreeGridService", "$timeout", "$http", function($scope, $gridService, $timeout, $http){

$scope.gridName = "gridSample";

$scope.columns = [];

$scope.rows = [];

 

$scope.loadRemote = function(){

var dataSource = $http.get('large-json.txt');

if (dataSource){

dataSource.success(function(data){

if (data.length == 2){

// Suspend the Layout

$gridService.suspendLayout($scope.gridName);

 

$gridService.clearColumns($scope.gridName);

$gridService.clearRows($scope.gridName);

 

// Add Columns

for (var j = 0; j < data[0].columns.length; j++)

$scope.columns.push(data[0].columns[j]);

 

// Add Rows

$gridService.loadData($scope.gridName, data[1].rows, null, null, true);

 

// Update the Layout

$gridService.resumeLayout($scope.gridName);

}

 

});

dataSource.error(function(data){

alert("AJAX failed to Load Data");

});

}

}

}]);

.iui-treegrid-column-header-cell, .iui-treegrid-column-footer-cell

{

padding: 1px 3px;

}

.iui-treegrid-row-cell-content

{

padding: 1px 3px;

}