Browse Source

整理

master
guy 8 years ago
parent
commit
7b5bbc48f3
  1. 57
      demo/js/base/table/demo.resizable_table.js
  2. 9
      demo/js/base/tree/demo.part_tree.js
  3. 9
      demo/js/base/tree/demo.sync_tree.js
  4. 52
      demo/js/base/tree/demo.tree_view.js
  5. 20
      demo/js/config/base.js
  6. 68
      demo/js/config/case.js
  7. 4
      demo/js/config/core.js
  8. 245
      demo/js/core/abstract/mvc.custom_tree.js
  9. 10
      dist/base.js
  10. 4
      dist/case.js
  11. 8
      src/base/combination/tree.button.js
  12. 2
      src/base/tree/treeview.js
  13. 2
      src/case/table/table.tree.js
  14. 2
      src/case/tree/tree.simple.js

57
demo/js/base/table/demo.resizable_table.js

@ -0,0 +1,57 @@
Demo.Func = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-func"
},
render: function () {
var items = [], header = [], columnSize = [];
var rowCount = 100, columnCount = 100;
for (var i = 0; i < 1; i++) {
header[i] = [];
for (var j = 0; j < columnCount; j++) {
header[i][j] = {
type: "bi.label",
text: "表头" + i + "-" + j
}
columnSize[j] = 100;
}
}
for (var i = 0; i < rowCount; i++) {
items[i] = [];
for (var j = 0; j < columnCount; j++) {
items[i][j] = {
type: "bi.label",
text: (i < 3 ? 0 : i) + "-" + j
}
}
}
var table = BI.createWidget({
type: "bi.resizable_table",
el: {
type: "bi.grid_table",
},
width: 600,
height: 500,
isResizeAdapt: true,
isNeedResize: true,
isNeedFreeze: true,
freezeCols: [0, 1],
columnSize: columnSize,
items: items,
header: header
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: table,
left: 10,
right: 10,
top: 10,
bottom: 10
}]
})
}
});
$.shortcut("demo.resizable_table", Demo.Func);

9
demo/js/base/tree/demo.part_tree.js

@ -0,0 +1,9 @@
Demo.Func = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-func"
},
render: function () {
}
});
$.shortcut("demo.part_tree", Demo.Func);

9
demo/js/base/tree/demo.sync_tree.js

@ -0,0 +1,9 @@
Demo.Func = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-func"
},
render: function () {
}
});
$.shortcut("demo.sync_tree", Demo.Func);

52
demo/js/base/tree/demo.tree_view.js

@ -0,0 +1,52 @@
Demo.Func = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-func"
},
_createDefaultTree: function(){
var tree = BI.createWidget({
type: "bi.tree_view"
});
tree.initTree([
{"id":1, "pId":0, "text":"test1", open:true},
{"id":11, "pId":1, "text":"test11"},
{"id":12, "pId":1, "text":"test12"},
{"id":111, "pId":11, "text":"test111"},
{"id":2, "pId":0, "text":"test2", open:true},
{"id":21, "pId":2, "text":"test21"},
{"id":22, "pId":2, "text":"test22"}
])
return tree;
},
render: function () {
var self = this;
BI.createWidget({
type: "bi.grid",
columns: 1,
rows: 1,
element: this,
items: [{
column: 0,
row: 0,
el: {
type: "bi.vtape",
items: [
{
el: this._createDefaultTree()
},
{
el: {
type: "bi.label",
text: 'tree.initTree([{"id":1, "pId":0, "text":"test1", open:true},{"id":11, "pId":1, "text":"test11"},{"id":12, "pId":1, "text":"test12"},{"id":111, "pId":11, "text":"test111"}])',
whiteSpace: "normal"
},
height: 50
}
]
}
}]
})
}
});
$.shortcut("demo.tree_view", Demo.Func);

20
demo/js/config/base.js

@ -69,23 +69,23 @@ Demo.BASE_CONFIG = [{
}, {
pId: 2,
id: 203,
text: "树控件"
text: "tree"
}, {
pId: 203,
text: "bi.treeview",
value: "demo.treeview"
text: "bi.tree_view",
value: "demo.tree_view"
}, {
pId: 203,
text: "bi.synctree",
value: "demo.synctree"
text: "bi.sync_tree",
value: "demo.sync_tree"
}, {
pId: 203,
text: "bi.parttree",
value: "demo.parttree"
text: "bi.part_tree",
value: "demo.part_tree"
}, {
pId: 2,
id: 204,
text: "表格"
text: "table"
}, {
pId: 204,
text: "bi.table_view",
@ -98,6 +98,10 @@ Demo.BASE_CONFIG = [{
pId: 204,
text: "bi.collection_table",
value: "demo.collection_table"
}, {
pId: 204,
text: "bi.resizable_table",
value: "demo.resizable_table"
}, {
pId: 2,
text: "bi.canvas",

68
demo/js/config/case.js

@ -54,6 +54,22 @@ Demo.CASE_CONFIG = [{
pId: 303,
text: "bi.level_tree",
value: "demo.level_tree"
}, {
pId: 3,
id: 304,
text: "table"
}, {
pId: 304,
text: "bi.adaptive_table",
value: "demo.adaptive_table"
}, {
pId: 304,
text: "bi.tree_table",
value: "demo.tree_table"
}, {
pId: 304,
text: "bi.layer_tree_table",
value: "demo.layer_tree_table"
}, {
pId: 3,
text: "bi.calendar",
@ -70,50 +86,8 @@ Demo.CASE_CONFIG = [{
pId: 3,
text: "bi.color_chooser",
value: "demo.color_chooser"
},
{
pId: 3,
text: "各种checkbox",
value: "demo.checkboxes"
}, {
pId: 3,
text: "各种tip",
value: "demo.tips"
}, {
pId: 3,
text: "bi.float_box",
value: "demo.float_box"
}, {
pId: 3,
text: "bi.float_box",
value: "demo.float_box"
}, {
pId: 3,
text: "bi.segment",
value: "demo.segment"
}, {
pId: 3,
id: 12,
text: "各种表格"
}, {
pId: 3,
id: 13,
text: "各种tree"
}, {
pId: 3,
text: "各种trigger",
value: "demo.triggers"
}, {
pId: 12,
text: "bi.adaptive_table",
value: "demo.adaptive_table"
}, {
pId: 12,
text: "bi.table_tree",
value: "demo.table_tree"
}, {
pId: 12,
text: "bi.layer_tree_table",
value: "demo.layer_tree_table"
}];
}, {
pId: 3,
text: "bi.segment",
value: "demo.segment"
}];

4
demo/js/config/core.js

@ -151,8 +151,8 @@ Demo.CORE_CONFIG = [{
value: "demo.layer_searcher"
}, {
pId: 102,
text: "bi.customtree",
value: "demo.customtree"
text: "bi.custom_tree",
value: "demo.custom_tree"
}, {
pId: 102,
text: "bi.grid_view",

245
demo/js/core/abstract/mvc.custom_tree.js

@ -0,0 +1,245 @@
Demo.Func = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-func"
},
_createDefaultTree: function () {
var TREEITEMS = [{id: -1, pId: -2, value: "根目录", open: true, type: "bi.plus_group_node", height: 25},
{id: 1, pId: -1, value: "第一级目录1", type: "bi.plus_group_node", height: 25},
{id: 11, pId: 1, value: "第二级文件1", type: "bi.single_select_item", height: 25},
{id: 12, pId: 1, value: "第二级目录2", type: "bi.plus_group_node", height: 25},
{id: 121, pId: 12, value: "第三级目录1", type: "bi.plus_group_node", height: 25},
{id: 122, pId: 12, value: "第三级文件1", type: "bi.single_select_item", height: 25},
{id: 1211, pId: 121, value: "第四级目录1", type: "bi.plus_group_node", height: 25},
{id: 12111, pId: 1211, value: "第五级文件1", type: "bi.single_select_item", height: 25},
{id: 2, pId: -1, value: "第一级目录2", type: "bi.plus_group_node", height: 25},
{id: 21, pId: 2, value: "第二级目录3", type: "bi.plus_group_node", height: 25},
{id: 22, pId: 2, value: "第二级文件2", type: "bi.single_select_item", height: 25},
{id: 211, pId: 21, value: "第三级目录2", type: "bi.plus_group_node", height: 25},
{id: 212, pId: 21, value: "第三级文件2", type: "bi.single_select_item", height: 25},
{id: 2111, pId: 211, value: "第四级文件1", type: "bi.single_select_item", height: 25}];
this.tree = BI.createWidget({
type: "bi.custom_tree",
el: {
type: "bi.button_tree",
chooseType: 0,
layouts: [{
type: "bi.vertical",
hgap: 30
}]
},
items: BI.deepClone(TREEITEMS)
});
return this.tree;
},
_createAsyncTree: function () {
this.asyncTree = BI.createWidget({
type: "bi.custom_tree",
itemsCreator: function (op, callback) {
if (!op.node) {//根节点
callback([{
"id": 1,
"pId": 0,
type: "bi.plus_group_node",
text: "test1",
value: 1,
height: 25,
isParent: true
}, {
"id": 2,
"pId": 0,
type: "bi.plus_group_node",
"text": "test2",
value: 1,
isParent: true,
open: true,
height: 25
}])
} else {
if (op.node.id == 1) {
callback([
{
"id": 11,
"pId": 1,
type: "bi.plus_group_node",
"text": "test11",
value: 11,
height: 25,
isParent: true
},
{
"id": 12,
"pId": 1,
type: "bi.single_select_item",
"text": "test12",
value: 12,
height: 35
},
{
"id": 13,
"pId": 1,
type: "bi.single_select_item",
"text": "test13",
value: 13,
height: 35
},
{
"id": 14,
"pId": 1,
type: "bi.single_select_item",
"text": "test14",
value: 14,
height: 35
},
{
"id": 15,
"pId": 1,
type: "bi.single_select_item",
"text": "test15",
value: 15,
height: 35
},
{
"id": 16,
"pId": 1,
type: "bi.single_select_item",
"text": "test16",
value: 16,
height: 35
},
{"id": 17, "pId": 1, type: "bi.single_select_item", "text": "test17", value: 17, height: 35}
])
} else if (op.node.id == 2) {
callback([{
"id": 21,
"pId": 2,
type: "bi.single_select_item",
"text": "test21",
value: 21,
height: 35
},
{
"id": 22,
"pId": 2,
type: "bi.single_select_item",
"text": "test22",
value: 22,
height: 35
}])
} else if (op.node.id == 11) {
callback([{
"id": 111,
"pId": 11,
type: "bi.single_select_item",
"text": "test111",
value: 111,
height: 35
}])
}
}
},
el: {
type: "bi.loader",
next: false,
el: {
type: "bi.button_tree",
chooseType: 0,
layouts: [{
type: "bi.vertical",
hgap: 30,
vgap: 0
}]
}
}
});
return this.asyncTree;
},
render: function () {
var self = this;
BI.createWidget({
type: "bi.grid",
columns: 2,
rows: 1,
element: this,
items: [{
column: 0,
row: 0,
el: {
type: "bi.vtape",
items: [
{
el: this._createDefaultTree()
},
{
el: {
type: "bi.center",
hgap: 10,
items: [{
type: "bi.text_button",
cls: "mvc-button layout-bg2",
text: "getValue",
height: 30,
handler: function () {
BI.Msg.alert("", JSON.stringify(self.tree.getValue()));
}
}, {
type: "bi.text_button",
cls: "mvc-button layout-bg2",
text: "getNodeByValue(第一级目录1)",
height: 30,
handler: function () {
BI.Msg.alert("", "节点名称为: " + self.tree.getNodeByValue("第一级目录1").getValue());
}
}]
},
height: 30
}
]
}
}, {
column: 1,
row: 0,
el: {
type: "bi.vtape",
items: [
{
type: "bi.label",
text: "异步加载数据",
height: 30
},
{
el: this._createAsyncTree()
},
{
el: {
type: "bi.center",
hgap: 10,
items: [{
type: "bi.text_button",
cls: "mvc-button layout-bg2",
text: "getValue",
height: 30,
handler: function () {
BI.Msg.alert("", JSON.stringify(self.asyncTree.getValue()));
}
}, {
type: "bi.text_button",
cls: "mvc-button layout-bg2",
text: "getNodeById(11)",
height: 30,
handler: function () {
BI.Msg.alert("", "节点名称为: " + (self.asyncTree.getNodeById(11) && self.asyncTree.getNodeById(11).getText()));
}
}]
},
height: 30
}
]
}
}]
})
}
});
$.shortcut("demo.custom_tree", Demo.Func);

10
dist/base.js vendored

@ -1438,13 +1438,13 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
var node;
BI.any(this.buttons, function (i, item) {
if (item.isEnabled()) {
if (item.getValue() === value) {
node = item;
return true;
} else if (BI.isFunction(item.getNodeByValue)) {
if (BI.isFunction(item.getNodeByValue)) {
if (node = item.getNodeByValue(value)) {
return true;
}
} else if (item.attr("value") === value) {
node = item;
return true;
}
}
});
@ -2073,7 +2073,7 @@ BI.TreeView.EVENT_CHANGE = "EVENT_CHANGE";
BI.TreeView.EVENT_INIT = BI.Events.INIT;
BI.TreeView.EVENT_AFTERINIT = BI.Events.AFTERINIT;
$.shortcut("bi.tree", BI.TreeView);/**
$.shortcut("bi.tree_view", BI.TreeView);/**
* guy
* 同步树
* @class BI.SyncTree

4
dist/case.js vendored

@ -9890,7 +9890,7 @@ BI.extend(BI.TableTree, {
}
});
$.shortcut("bi.table_tree", BI.TableTree);/**
$.shortcut("bi.tree_table", BI.TableTree);/**
* guy
* 复选导航条
* Created by GUY on 2015/8/25.
@ -10344,7 +10344,7 @@ BI.SimpleTreeView = BI.inherit(BI.Widget, {
var self = this, o = this.options;
this.structure = new BI.Tree();
this.tree = BI.createWidget({
type: "bi.tree",
type: "bi.tree_view",
element: this,
itemsCreator: function (op, callback) {
var fn = function (items) {

8
src/base/combination/tree.button.js

@ -164,13 +164,13 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
var node;
BI.any(this.buttons, function (i, item) {
if (item.isEnabled()) {
if (item.getValue() === value) {
node = item;
return true;
} else if (BI.isFunction(item.getNodeByValue)) {
if (BI.isFunction(item.getNodeByValue)) {
if (node = item.getNodeByValue(value)) {
return true;
}
} else if (item.attr("value") === value) {
node = item;
return true;
}
}
});

2
src/base/tree/treeview.js

@ -504,4 +504,4 @@ BI.TreeView.EVENT_CHANGE = "EVENT_CHANGE";
BI.TreeView.EVENT_INIT = BI.Events.INIT;
BI.TreeView.EVENT_AFTERINIT = BI.Events.AFTERINIT;
$.shortcut("bi.tree", BI.TreeView);
$.shortcut("bi.tree_view", BI.TreeView);

2
src/case/table/table.tree.js

@ -327,4 +327,4 @@ BI.extend(BI.TableTree, {
}
});
$.shortcut("bi.table_tree", BI.TableTree);
$.shortcut("bi.tree_table", BI.TableTree);

2
src/case/tree/tree.simple.js

@ -18,7 +18,7 @@ BI.SimpleTreeView = BI.inherit(BI.Widget, {
var self = this, o = this.options;
this.structure = new BI.Tree();
this.tree = BI.createWidget({
type: "bi.tree",
type: "bi.tree_view",
element: this,
itemsCreator: function (op, callback) {
var fn = function (items) {

Loading…
Cancel
Save