1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- let MultipleViewData = require('MultipleViewData')
- cc.Class({
- extends: MultipleViewData,
- initRoot (rootNode) {
- this._super(rootNode);
- this.datas = [];
- this.createIndex = 0;
- return this;
- },
- addDatas(datas) {
- this.datas = datas
- },
- getCells() {
- return this.cells;
- },
- startCreate(type, parent, cb) {
- this.createIndex = 0
- this.cells = [];
- parent.removeAllChildren()
- this.createView(type, parent, cb);
- },
- createView(type, parent, cb) {
- if (this.createIndex >= this.datas.length) {
- return;
- }
- let data = this.datas[this.createIndex]
- let self = this
- this.rootNode.createComponent(type, parent, data, function(node, status) {
- if (status != 'ok') {
- return
- }
- let index = self.createIndex
- self.createIndex += 1;
- self.cells.push(node);
- self.createView(type, parent, cb);
- if (cb) {
- cb(node, index, data);
- }
- })
- },
- })
|