您好,请参照
- loadColumnLayout() {
- if (localStorage) {
- if (!localStorage['columns']) {
- alert('Please save a layout first...');
- } else {
- this.flex.columnLayout = localStorage['columns'];
- var colCountry = this.flex.columns.getColumn('countryId');
- var colProduct = this.flex.columns.getColumn('productId');
- var colColor = this.flex.columns.getColumn('colorId');
- if (colCountry && colProduct && colColor) {
- if (this.dataMaps == true) {
- colCountry.showDropDown = true; // show drop-down for countries
- colProduct.showDropDown = false; // don't show it for products
- colColor.showDropDown = false; // or colors (just to show how)
- colCountry.dataMap = this._buildDataMap(this.dataSvc.getSomeCountries());
- colProduct.dataMap = this._buildDataMap(this.dataSvc.getProducts());
- colColor.dataMap = this._buildDataMap(this.dataSvc.getColors());
- } else {
- colCountry.dataMap = null;
- colProduct.dataMap = null;
- colColor.dataMap = null;
- }
- }
- console.log('** Loaded layout: ' + this.flex.columnLayout);
- }
- }
- }
复制代码- public _buildDataMap(items): wjcGrid.DataMap {
- var map = [];
- for (var i = 0; i < items.length; i++) {
- map.push({ key: i, value: items[i] });
- }
- return new wjcGrid.DataMap(map, 'key', 'value');
- }
复制代码
该例子是基于ts写的,js请参照,您说的buildDataMap是自己写的。
具体在您的安装下面的sample 有相应的示例。 |