求问,spreadjs怎么设置初始化排序,代码如下所示,但是没有生效
- var sheet = spread.getSheet(0);
- var data = {
- name: 'Jones', region: 'East',
- sales: [
- { orderDate: '活动', item: 'Pencil', units: 95, cost: 1.99, operation: '操作' },
- { orderDate: '活动', item: 'Pencil', units: 60, cost: 4.99, operation: '操作' },
- { orderDate: '活动', item: 'PenSet', units: 16, cost: 15.99, operation: '操作' }
- ]
- };
- let tableColumns = [];
- let names = ['orderDate', 'item', 'units', 'cost', 'operation'];
- let labels = ['Order Date', 'Item', 'Units', 'Cost', 'Operation'];
- let table = sheet.tables.add('tableRecords', 0, 0, 4, 5);
- table.autoGenerateColumns(false);
- names.forEach(function (name, index) {
- let tableColumn = new GC.Spread.Sheets.Tables.TableColumn();
- tableColumn.name(labels[index]);
- tableColumn.dataField(name);
- tableColumns.push(tableColumn);
- });
- table.bindColumns(tableColumns);
- table.bindingPath('sales');
- let source = new GC.Spread.Sheets.Bindings.CellBindingSource(data);
- sheet.setDataSource(source);
- // 初始化排序
- sheet.sortRange(1, 0, 3,5, true, [{
- index: 2,
- ascending: true
- }]);
- sheet.invalidateLayout();
- sheet.repaint();
复制代码
|