demo具体文件就不传了,代码很少的。具体代码如下:
1.html页面:
<div ng-app="app" ng-controller="appCtrl" class="container">
<h1> AngularJS 下 Wijmo 5 的格式保存</h1>
<br/>
<wj-flex-grid items-source="data" control="sourceControl" is-read-only="false">
<wj-flex-grid-column header="国家" binding="country"></wj-flex-grid-column>
<wj-flex-grid-column header="币种" binding="currency">
<wj-flex-grid-cell-template cell-type="CellEdit">
<wj-combo-box items-source="currency_selectArr" selected-value="$value" is-editable="false"></wj-combo-box>
</wj-flex-grid-cell-template>
</wj-flex-grid-column>
<wj-flex-grid-column header="销售额" binding="sales"></wj-flex-grid-column>
<wj-flex-grid-column header="利润额" binding="expenses"></wj-flex-grid-column>
</wj-flex-grid>
<br/>
<button ng-click="saveColumnLayout()">格式保存</button>
<button ng-click="loadColumnLayout()">格式载入</button>
</div>
2.js内容:
// define app, include Wijmo 5 directives
var app = angular.module('app', ['wj']);
// controller
app.controller('appCtrl', function($scope) {
$scope.currency_selectArr = ["RMB","USD"];//币种下拉框取数
// create some random data
var countries = '英国,德国,美国,日本,意大利'.split(','),
data = [];
for (var i = 0; i < countries.length; i++) {
data.push({
country: countries,
currency: i%2==1?"USD":"RMB",
sales: Math.random() * 10000,
expenses: Math.random() * 5000
});
};
$scope.data = new wijmo.collections.CollectionView(data);
//格式保存按钮
$scope.saveColumnLayout = function() {
localStorage['columns'] = $scope.sourceControl.columnLayout;
};
//格式载入按钮
$scope.loadColumnLayout = function() {
var columnLayout = localStorage['columns'];
if (columnLayout) {
$scope.sourceControl.columnLayout = columnLayout;
}
};
});
-----以上拷贝执行下,效果就是 先点格式保存,再点格式载入,币种那一整列编辑时就不能下拉框选择了
|