FineUI 官方论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

本论坛已关闭(禁止注册、发帖和回复)
请移步 三石和他的朋友们

FineUI首页 WebForms - MVC & Core - JavaScript 常见问题 - QQ群 - 十周年征文活动

FineUI(开源版) 下载源代码 - 下载空项目 - 获取ExtJS - 文档 在线示例 - 版本更新 - 捐赠作者 - 教程

升级到 ASP.NET Core 3.1,快、快、快! 全新ASP.NET Core,比WebForms还简单! 欢迎加入【三石和他的朋友们】(基础版下载)

搜索
查看: 2676|回复: 4
打印 上一主题 下一主题

基于FineUI的PropertyGrid

[复制链接]
跳转到指定楼层
楼主
发表于 2020-1-5 21:33:33 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 棕榈 于 2020-1-5 21:25 编辑

基于FineUI的PropertyGrid




属性网格对于从事WinForm开发的程序员来说应该是相当熟悉的了,但在Web开发中几乎看不到它的身影,这么方便的工具为什么在Web开发中很少用到呢,这背后的原因有很多,这里也不作讨论。平时我们并不能用到它,那我为什么还要做这一个组件呢,这与我正在开发的可视化设计器有关,它将用于设计器中的属性设置部分,这款设计器包含UI设计、EF实体设计、流程图设计,设计器的界面采用FineUI实现,关于设计器的详细信息以后会有介绍。



属性网格的数据包含两部分,一部分是类型定义,另一部分是对象数据

类型定义:采用的是JsonSchema,用它定义及约束类型,它的格式大概是这样的,由于完整的代码太多,这里只是部分

  1. {
  2.   "definitions": {},
  3.   "$schema": "http://json-schema.org/draft-07/schema#",
  4.   "$id": "http://example.com/root.json",
  5.   "type": "object",
  6.   "title": "The Root Schema",
  7.   "required": ["SingleLine", "Integer", "Number", "Date", "Color"],
  8.   "properties": {
  9.     "SingleLine": {
  10.       "$id": "#/properties/SingleLine",
  11.       "type": "string",
  12.       "title": "输入单行文本",
  13.       "default": "单行文本",
  14.       "examples": ["单行文本"]
  15.     },
  16.     "Multiline": {
  17.       "$id": "#/properties/Multiline",
  18.       "type": "string",
  19.       "title": "输入多行文本",
  20.       "format": "multiline",
  21.       "default": "",
  22.       "examples": ["多行文本"]
  23.     },
  24.     "Description": {
  25.       "$id": "#/properties/Description",
  26.       "type": "string",
  27.       "title": "描述HTML格式,<a href='http://wwww.baidu.com'><b>单击</b>查看详情</a>",
  28.       "default": "描述",
  29.       "examples": ["描述"]
  30.     },
  31.     "DropdownList2": {
  32.       "$id": "#/properties/DropdownList2",
  33.       "type": "string",
  34.       "title": "多选下拉下列表且名称与值为不同的值",
  35.       "format": "dropdownlist",
  36.       "multiSelect": true,
  37.       "dropdownlist": [
  38.         ["value1", "item1"],
  39.         ["value2", "item2"],
  40.         ["value3", "item3"],
  41.         ["value4", "item4"],
  42.         ["value5", "item5"]
  43.       ],
  44.       "default": "value2,value3",
  45.       "examples": ["value1,value2"]
  46.     },

  47. ...
  48. ...
  49. ...
  50. ...

  51.     "DropdownList4": {
  52.       "$id": "#/properties/DropdownList4",
  53.       "type": "string",
  54.       "title": "下拉下列可编辑输入且强制选择",
  55.       "format": "dropdownlist",
  56.       "editable": true,
  57.       "dropdownlist": [
  58.         ["value1", "item1"],
  59.         ["value2", "item2"],
  60.         ["value3", "item3"],
  61.         ["value4", "item4"],
  62.         ["value5", "item5"]
  63.       ],
  64.       "default": "value3",
  65.       "examples": ["value1"]
  66.     },
  67.     "Number": {
  68.       "$id": "#/properties/Number",
  69.       "type": "number",
  70.       "title": "输入小数",
  71.       "minimum": -100,
  72.       "maximum": 100,
  73.       "default": 60.8,
  74.       "examples": [0.1]
  75.     },
  76.     "Size": {
  77.       "$id": "#/properties/Size",
  78.       "type": "object",
  79.       "title": "大小对象包含宽度与高度",
  80.       "required": ["Width", "Height"],
  81.       "text": ["{0},{1}", "Size-Width", "Size-Height"],
  82.       "default": "20,20",
  83.       "properties": {
  84.         "Width": {
  85.           "$id": "#/properties/Size/properties/Width",
  86.           "type": "integer",
  87.           "title": "Width",
  88.           "minimum": 0,
  89.           "maximum": 500,
  90.           "default": 20,
  91.           "examples": [200]
  92.         },
  93.         "Height": {
  94.           "$id": "#/properties/Size/properties/Height",
  95.           "type": "integer",
  96.           "title": "Height",
  97.           "minimum": 0,
  98.           "maximum": 500,
  99.           "default": 20,
  100.           "examples": [100]
  101.         }
  102.       }
  103.     },
  104.     "Array": {
  105.       "$id": "#/properties/Array",
  106.       "type": "array",
  107.       "title": "字符串数组类型",
  108.       "items": {
  109.         "$id": "#/properties/Array/items",
  110.         "type": "string",
  111.         "title": "字符串",
  112.         "default": "",
  113.         "examples": ["string1", "string2", "string3", "string4", "string5"]
  114.       }
  115.     }
  116. ...
  117. ...
  118. ...
  119.   }
  120. }
复制代码

这是Number类型的定义

  1.     "Number": {
  2.       "$id": "#/properties/Number",
  3.       "type": "number",
  4.       "title": "输入小数",
  5.       "minimum": -100,
  6.       "maximum": 100,
  7.       "default": 60.8,
  8.       "examples": [0.1]
  9.     }
复制代码


这是下拉列表类型的定义

  1.     "DropdownList4": {
  2.       "$id": "#/properties/DropdownList4",
  3.       "type": "string",
  4.       "title": "下拉下列可编辑输入且强制选择",
  5.       "format": "dropdownlist",
  6.       "editable": true,
  7.       "dropdownlist": [
  8.         ["value1", "item1"],
  9.         ["value2", "item2"],
  10.         ["value3", "item3"],
  11.         ["value4", "item4"],
  12.         ["value5", "item5"]
  13.       ],
  14.       "default": "value3",
  15.       "examples": ["value1"]
  16.     }
复制代码

这是Size对象的定义

  1. "Size": {
  2.   "$id": "#/properties/Size",
  3.   "type": "object",
  4.   "title": "大小对象包含宽度与高度",
  5.   "required": ["Width", "Height"],
  6.   "text": ["{0},{1}", "Size-Width", "Size-Height"],
  7.   "converter": "(function(){if(data&&typeof data=='string'&&data.length>0) ...",
  8.   "default": "20,20",
  9.   "properties": {
  10.         "Width": {
  11.           "$id": "#/properties/Size/properties/Width",
  12.           "type": "integer",
  13.           "title": "Width",
  14.           "minimum": 0,
  15.           "maximum": 500,
  16.           "default": 20,
  17.           "examples": [200]
  18.         },
  19.         "Height": {
  20.           "$id": "#/properties/Size/properties/Height",
  21.           "type": "integer",
  22.           "title": "Height",
  23.           "minimum": 0,
  24.           "maximum": 500,
  25.           "default": 20,
  26.           "examples": [100]
  27.         }
  28.   }
  29. }
复制代码


对象数据:采用的是Json,代码如下:

  1. {
  2.   "SingleLine": "单行文本",
  3.   "DropdownList": "item1",
  4.   "DropdownList2": "value1,value2",
  5.   "DropdownList3": "value3",
  6.   "DropdownList4": "value4",
  7.   "Boolean": false,
  8.   "Integer": 50,
  9.   "Number": 60.8,
  10.   "Color": "#CCCCCC",
  11.   "Size": {
  12.     "Width": 200,
  13.     "Height": 100
  14.   },
  15.   "Padding": {
  16.     "Left": 10,
  17.     "Top": 20,
  18.     "Right": 10,
  19.     "Bottom": 20
  20.   },
  21.   "Object": {
  22.     "Name": "Address",
  23.     "Type": "string",
  24.     "IsNull": false,
  25.     "Remark": "家庭住址"
  26.   },
  27.   "Array": ["string1", "string2", "string3", "string4", "string5"],
  28.   "KeyValuePair": [{
  29.       "key": "Key1",
  30.       "value": "Value1"
  31.     },
  32.     {
  33.       "key": "Key2",
  34.       "value": "Value2"
  35.     },
  36.     {
  37.       "key": "Key3",
  38.       "value": "Value3"
  39.     },
  40.     {
  41.       "key": "Key4",
  42.       "value": "Value4"
  43.     },
  44.     {
  45.       "key": "Key5",
  46.       "value": "Value5"
  47.     }
  48.   ]
  49. }
复制代码


关于JsonSchema网上介绍它的文章有很多,大家可以百度搜索,有什么不明白的可以留言。


属性网格是在FineUI的树组件上构建的,搜索栏是一个工具栏,描述栏也是一个工具栏,中间是一个树的主体部分。





搜索栏,可以通过输入属性名称的部分信息来过虑属性





描述栏,当选择一个属性时将显示属性的描述信息,描述信息支持HTML格式





属性编辑器,包含大多数常用的编辑器,如:
1、单选文本
2、多行文本
3、下拉选择(单选、多选、输入等)
4、枚举
5、布尔型
6、整数
7、小数
8、日期
9、颜色
10、对象类型
11、文本数组
12、键值对数组
13、文件上传

后续会根据设计器的需求,再增加一些编辑器


为了配合属性网格的使用,对部分编辑器做了一些增强
1、每一个编辑器的清除按钮是用于将属性重置到默认值,为了保持统一,对数字输入框添加了清除按钮
2、为了便于输入多行文本,增加了一个下拉的多行文本输入框
3、引入了一个第三方的颜色拾取器,并对其增加了下拉功能,下拉效果是用FineUI来实现的
4、可以直接编辑对象或编辑对象属性,如Size对象,对象的编辑及显示是通过JsonSchema来定义的
5、提供了一个键值对数组的编辑器,可以对其进行添加、删除、上移、下移等操作


属性网格的实现将大大方便了设计器的操作,大家对基于FineUI的可视化设计器有什么想法,可以留言给我。



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
沙发
发表于 2020-1-5 23:07:59 | 只看该作者
太酷了,中间居然是个Tree,那文本框编辑是怎么实现的哪?
板凳
发表于 2020-1-6 10:42:02 | 只看该作者
的确牛!!能开源学习一下吗?
地板
发表于 2020-1-6 14:48:18 | 只看该作者
⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ 666 ⁶⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶66⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶666⁶⁶⁶⁶⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶66⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶6666⁶⁶666 666 ⁶⁶⁶⁶⁶⁶ 666666 ⁶⁶⁶ 66666 ⁶⁶⁶66⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ 666 ⁶⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶66⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶666⁶⁶⁶⁶⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶66⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶6666⁶⁶666 666 ⁶⁶⁶⁶⁶⁶ 666666 ⁶⁶⁶ 66666 ⁶⁶⁶66⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ 666 ⁶⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶66⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶666⁶⁶⁶⁶⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶66⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶6666⁶⁶666 666 ⁶⁶⁶⁶⁶⁶ 666666 ⁶⁶⁶ 66666 ⁶⁶⁶66⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ 666 ⁶⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶66⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶666⁶⁶⁶⁶⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶66⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶6666⁶⁶666 666 ⁶⁶⁶⁶⁶⁶ 666666 ⁶⁶⁶ 66666 ⁶⁶⁶66⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ 666 ⁶⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶66⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶666⁶⁶⁶⁶⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶66⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶6666⁶⁶666 666 ⁶⁶⁶⁶⁶⁶ 666666 ⁶⁶⁶ 66666 ⁶⁶⁶66⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ 666 ⁶⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶66⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶666⁶⁶⁶⁶⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶66⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶6666⁶⁶666 666 ⁶⁶⁶⁶⁶⁶ 666666 ⁶⁶⁶ 66666 ⁶⁶⁶66⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ 666 ⁶⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶66⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶666⁶⁶⁶⁶⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶66⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶6666⁶⁶666 666 ⁶⁶⁶⁶⁶⁶ 666666 ⁶⁶⁶ 66666 ⁶⁶⁶66⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ 666 ⁶⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶66⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶666⁶⁶⁶⁶⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶66⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶6666⁶⁶666 666 ⁶⁶⁶⁶⁶⁶ 666666 ⁶⁶⁶ 66666 ⁶⁶⁶66⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ 666 ⁶⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶66⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶666⁶⁶⁶⁶⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶66⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶6666⁶⁶666 666 ⁶⁶⁶⁶⁶⁶ 666666 ⁶⁶⁶ 66666 ⁶⁶⁶66⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ 666 ⁶⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶66⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶666⁶⁶⁶⁶⁶⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶⁶66⁶⁶⁶⁶ ⁶⁶⁶⁶⁶⁶ ⁶6666⁶⁶666 666 ⁶⁶⁶⁶⁶⁶ 666666 ⁶⁶⁶ 66666 ⁶⁶⁶66
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|FineUI 官方论坛 ( 皖ICP备2021006167号-1 )

GMT+8, 2024-4-19 22:49 , Processed in 0.050715 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表