I run this code from bwu_datagrid example in Dart Editor:
pubspec.yaml
name: 'basicExample'
version: 0.0.1
description: A web app built using polymer.dart.
environment:
sdk: '>=1.0.0 <2.0.0'
dependencies:
browser: '>=0.10.0 <0.11.0'
polymer: '>=0.16.0 <0.17.0'
bwu_datagrid: any
js: any
transformers:
- polymer:
entry_points: web/index.html
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="scaffolded-by" content="https://github.com/google/stagehand">
<title>basicExample</title>
<link rel="import" href="packages/basicExample/app_element.html">
<link rel='stylesheet' href='example.css'>
</head>
<body>
<h3>Some table</h3>
<app-element></app-element>
<script type="application/dart">export 'package:polymer/init.dart';</script>
</body>
</html>
app_element.html
<!DOCTYPE html>
<link rel="import" href="../../packages/polymer/polymer.html">
<link rel='import' href='../../packages/bwu_datagrid/bwu_datagrid.html'>
<polymer-element name='app-element'>
<template>
<!--<link rel='stylesheet' href='packages/bwu_datagrid/asset/grid.css'>
<link rel='stylesheet' href='packages/bwu_datagrid/asset/default_theme.css' > -->
<!-- link rel='stylesheet' href='../web/example.css' -->
<style>
:host {
display: block;
width: 100%;
}
table {
width: 100%;
}
</style>
<table>
<tr>
<td valign='top' width='50%'>
<bwu-datagrid id='myGrid' style='width:600px;height:500px;'></bwu-datagrid>
</td>
<td valign='top'>
<h2>Demonstrates:</h2>
<ul>
<li>basic grid with minimal configuration</li>
</ul>
<h2>View Source:</h2>
<ul>
<li><A href='https://github.com/bwu-dart/bwu_datagrid/blob/master/example/src/e01_simple/app_element.dart' target='_sourcewindow'> View the source for this example on Github</a></li>
</ul>
</td>
</tr>
</table>
</template>
<script type='application/dart' src='app_element.dart'></script>
</polymer-element>
app_element.dart
library app_element;
import 'dart:math' as math;
import 'package:polymer/polymer.dart';
import 'package:bwu_datagrid/datagrid/helpers.dart';
import 'package:bwu_datagrid/bwu_datagrid.dart';
@CustomTag('app-element')
class AppElement extends PolymerElement {
AppElement.created() : super.created();
BwuDatagrid grid;
List<Column> columns = [
new Column(id: 'title', name: 'Title', field: 'title'),
new Column(id: 'duration', name: 'Duration', field: 'duration'),
new Column(id: '%', name: '% Complete', field: 'percentComplete'),
new Column(id: 'start', name: 'Start', field: 'start'),
new Column(id: 'finish', name: 'Finish', field: 'finish'),
new Column(
id: 'effort-driven', name: 'Effort Driven', field: 'effortDriven')
];
var gridOptions = new GridOptions(enableCellNavigation: true, enableColumnReorder: false);
@override
void attached() {
super.attached();
try {
grid = $['myGrid'];
var data = new MapDataItemProvider(); //List<Map>(500);
for (var i = 0; i < 500; i++) {
data.items.add(new MapDataItem({
'title': 'Task ${i}',
'duration': '5 days',
'percentComplete': new math.Random().nextInt(100).round(),
'start': '01/01/2009',
'finish': '01/05/2009',
'effortDriven': (i % 5 == 0)
}));
}
grid.setup(dataProvider: data, columns: columns, gridOptions: gridOptions);
} on NoSuchMethodError catch (e) {
print('$e\n\n${e.stackTrace}');
print ('it is not worked -1-');
} on RangeError catch (e) {
print('$e\n\n${e.stackTrace}');
print ('it is not worked -2-');
} on TypeError catch (e) {
print('$e\n\n${e.stackTrace}');
print ('it is not worked -3-');
} catch (e) {
print('$e');
print ('it is not worked -4-');
}
}
}
When I run this code in Dart Editor, I get an error:
Observatory listening at http://127.0.0.1:59681/
Exception: Uncaught Error: Invalid argument (value): Not a valid class token: ""
Stack Trace:
#0 CssClassSetImpl._validateToken (file:///mnt/data/b/build/slave/dartium-lucid64-full-stable/build/src/dart/sdk/lib/html/html_common/css_class_set.dart:13)
#1 CssClassSetImpl.add (file:///mnt/data/b/build/slave/dartium-lucid64-full-stable/build/src/dart/sdk/lib/html/html_common/css_class_set.dart:108)
#2 BwuDatagrid._createColumnHeaders (package:bwu_datagrid/bwu_datagrid.dart:749:21)
#3 BwuDatagrid._finishInitialization (package:bwu_datagrid/bwu_datagrid.dart:369:7)
#4 BwuDatagrid._init (package:bwu_datagrid/bwu_datagrid.dart:333:7)
#5 BwuDatagrid.setup.<anonymous closure> (package:bwu_datagrid/bwu_datagrid.dart:184:9)
#6 Future.Future.<anonymous closure> (dart:async/future.dart:118)
#7 Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:16)
#8 _Timer._Timer.<anonymous closure> (dart:html:42314)
Why I get this problem? Thank you.
I use CentOS 7 and Dart 1.10.0.
This is a known problem caused by a breaking change in Dart 1.10.
- https://github.com/bwu-dart/bwu_datagrid/pull/108
- https://github.com/bwu-dart/bwu_datagrid/issues/106
I try to get an updated version published ASAP.