一 新建数据表
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for syc_dir
-- ----------------------------
DROP TABLE IF EXISTS `syc_dir`;
CREATE TABLE `syc_dir` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
`num` int(11) NULL DEFAULT NULL COMMENT '排序',
`pid` int(11) NULL DEFAULT NULL COMMENT '父ID',
`pids` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '父级ids',
`simplename` varchar(100) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '简称',
`fullname` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '全称',
`tips` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '提示',
`version` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '扩展',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8 COLLATE = utf8_bin COMMENT = '商家分类表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of syc_dir
-- ----------------------------
INSERT INTO `syc_dir` VALUES (4, NULL, 0, '', '餐饮', '餐饮', '', '');
INSERT INTO `syc_dir` VALUES (5, NULL, 0, '', '住宿', '住宿', '', '');
INSERT INTO `syc_dir` VALUES (6, NULL, 0, '', '娱乐', '娱乐', '', '');
INSERT INTO `syc_dir` VALUES (7, NULL, 4, '', '烧烤', '烧烤', '', '');
INSERT INTO `syc_dir` VALUES (8, NULL, 4, '', '火锅', '火锅', '', '');
INSERT INTO `syc_dir` VALUES (9, NULL, 5, '', '酒店', '酒店', '', '');
INSERT INTO `syc_dir` VALUES (10, NULL, 5, '', '快捷宾馆', '快捷宾馆', '', '');
SET FOREIGN_KEY_CHECKS = 1;
顶级pid 为0 否则折叠会报错
二 自动生成表 (略)
关于guns-rest 下面生成表 默认表前缀也出现 是驼峰法
去掉表前缀 加上:
···
strategy.setTablePrefix("syc_");
···
三 在dir.js 中
$(function () {
/* var defaultColunms = Dir.initColumn();
var table = new BSTable(Dir.id, "/dir/list", defaultColunms);
table.setPaginationType("client");
Dir.table = table.init();*/
var defaultColunms = Dir.initColumn();
var table = new BSTreeTable(Dir.id, "/dir/list", defaultColunms);
table.setExpandColumn(2);
table.setIdField("id");
table.setCodeField("id");
table.setParentCodeField("pid");
table.setExpandAll(true);
table.init();
Dir.table = table;
});
就显示出来了,而点击折叠和展开 需要在将Dir.check 中改下
···
//var selected = ('#' + this.id).bootstrapTreeTable('getSelections');
····
至此就可以显示出来了!
网友评论