• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ngx-property-grid: A small and simple property grid in angular to view/edit POJO ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

ngx-property-grid

开源软件地址:

https://gitee.com/mokeyish/ngx-property-grid

开源软件介绍:

NgxPropertyGrid

License: MITnpm versionBuild Status

A small and simple property grid in angular to view/edit POJOs, excellent if you have a "settings" object you want to give the user to edit (that's why I have created it). Play online.

Dependencies

Usage

  1. Import
    import {PropertyGridModule} from 'ngx-property-grid';import {NgxTemplateModule} from 'ngx-template';
    If you need animation,you should import BrowserAnimationsModule in your app.module.ts.
  2. Getting Started
    • Html
      • Basic
        <ngx-property-grid [width]="'300px'" [options]="editor"></ngx-property-grid>
      • Template
        <ngx-property-grid [width]="'300px'" [options]="editor">    <ng-template ngxTemplate="text" let-p>        <input type="text" [value]="p.value" (change)="p.value = $event.target.value">    </ng-template>    <ng-template ngxTemplate="color" let-p>        <input type="color" [value]="p.value" (change)="p.value = $event.target.value">    </ng-template></ngx-property-grid>
    • Object options
      export class ExampleEditorOptions {    @meta({name: 'Font', description: 'The font editor to use', type: SimpleTextEditorComponent, group: 'Editor', hidden: false})    font = 'Source Code Pro';    @meta({name: 'Font size', group: 'Editor', type: 'number', valueConvert: parseInt})    fontSize = 14;    @meta({name: 'Font color', group: 'Editor', type: 'color'})    fontColor = '#51f41c';    @meta({name: 'jQuery', group: 'Plugins', type: 'checkbox'})    jQuery = true;    @meta({name: 'modernizr', description: 'Whether or not to include modernizr on the page', group: 'Plugins', type: 'checkbox'})    modernizr = false;    @meta({        name: 'Framework',        description: 'Whether to include any additional framework',        type: 'options',        options: ['None', {text: 'AngularJS', value: 'angular'}, {text: 'Backbone.js', value: 'backbone'}]    })    framework = 'None';}
  3. The metadata options declare
 export interface PropertyItemMeta {    name: string; // The display name of the property in the grid    description?: string; // A description of the property, will be used as tooltip on an hint element (a span with text "[?]")    order?: number; // The display order.    group?: string; //  The group this property belongs to    hidden?: boolean; // Whether this property should be hidden in the grid, default is false (can be omitted).    initState?: string; // - hidden/visible. If hidden then subItems should init by hidden state. default is hidden    type?: 'color' | 'date' | 'checkbox' | 'text' | 'options' | string | Type<ControlValueAccessor | ICustomDynamicComponent<any>>;    // options: boolean number options label color,    // or an custom component should be implement ControlValueAccessor or ICustomDynamicComponent<any>    options?: any; // options for type    colSpan2?: boolean; //  - true/false. If true then property input will span both columns and will have no name/label    // (useful for textarea custom type)    valueConvert?: (value: any) => any; // convert the value, eg. parseInt}

The metadata object

As seen from the example above the metadata object can be used (it's optional) in order to describe the object properties.Each proprty in the metadata object could have the following:

  • name - The display name of the property in the grid
  • description - A description of the property, will be used as tooltip on an hint element (a span with text "[?]")
  • hidden - Whether this property should be hidden in the grid, default is false (can be omitted).
  • group - The group this property belongs to
  • type - The type of the property, supported are:
    • boolean or checkbox - A checkbox would be used
    • number - simple textbox
    • color - simple textbox
    • options - A dropdown list would be used in case the metadata contains the options array property
    • label - A label will be used, useful for uneditable / read-only properties
  • colspan2 - true/false. If true then property input will span both columns and will have no name/label (useful for textarea custom type)

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
ngEditor: angular editor发布时间:2022-02-14
下一篇:
ng-util: A set of Angular utilities发布时间:2022-02-14
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap