Giter Site home page Giter Site logo

element-tree-grid's Introduction

element-tree-grid

Version Downloads

tree grid extends element ui with vue

releases v1.0.4

  • try to expand row expanded after data reload

having problems with <el-table-column type="selection" fixed></el-table-column>

if you have any idea , welcome !!!

demos

start

  • clone to your project

    git clone https://github.com/foolishchow/element-tree-grid.git
    cd element-tree-grid
    npm install #or yarn
    npm run dev
  • use with node

    • install
    npm install element-tree-grid --save
    • in you project
    //common 
    var ElTreeGrid = require('element-tree-grid');
    Vue.component(ElTreeGrid.name,ElTreeGrid);

useage

  • common useage

    <el-table :data="model.menus" border max-height="250">
        <el-table-tree-column 
            file-icon="icon icon-file" 
            folder-icon="icon icon-folder" 
            prop="label" label="labelname" width="220"></el-table-tree-column>
        <el-table-column prop="description" label="description"   width="180"></el-table-column>
    </el-table>
  • get children from remote

    • html
    <div id="app" style="padding: 30px;">
        <el-table :data="model.menus" border max-height="400">
            <el-table-tree-column 
                :remote="remote"
                file-icon="icon icon-file" 
                folder-icon="icon icon-folder" 
                prop="label" label="MenuName" width="320"></el-table-tree-column>
            <el-table-column prop="id" label="id" width="180"></el-table-column>
            <el-table-column prop="description" label="Description" :show-overflow-tooltip="true" width="180"></el-table-column>
        </el-table>
    </div>
    • javascript
    new Vue({
        el: "#app",
        data: {
            model: {
                menus: trees
            }
        },
        methods:{
            remote(row,callback){
                // async or sync are both supported
                setTimeout(function() {
                    callback(row.children)
                },500)
            }
        }
    })
  • attributes

    all props of el-table-column are supported;

    name description values
    prop same as el-table-column
    label same as el-table-column
    width same as el-table-column
    fixed same as el-table-column
    resizable same as el-table-column
    formatter same as el-table-column
    className same as el-table-column
    treeKey the key for neasted parse type:String,
    default:'id'
    childNumKey the key of childNum type:String,
    default:'child_num'
    parentKey the key of parent_id type:String,
    default:'parent_id'
    levelKey the key of node's depth type:String,
    default:'depth'
    childKey the key of node's children been placed type:String,
    default:'children'
    fileIcon file icon className type:String,
    default:'el-icon-file'
    folderIcon folder icon className ,when opend use: folderIcon-open type:String,
    default:'el-icon-folder'
    remote remote method to get children type:Function,
    default:null
    allRemote request all data from remote ,you have to config prop remote first,default use request cache type:Boolean,
    default:false
    expandAll expand all nodes when loaded type:Boolean,
    default:false
    expandKey key tells if the line is opened at inited ( just expended once ) type:String,
    default:expanded
    indentSize indent number ,united in px type:Number,
    default:14

examples

  • common
<el-table-tree-column 
            file-icon="icon icon-file" 
            folder-icon="icon icon-folder" 
            prop="label" 
            label="labelname" 
            width="220"></el-table-tree-column>
  • with formatter
<el-table-tree-column 
            file-icon="icon icon-file" 
            folder-icon="icon icon-folder" 
            prop="label" 
            label="labelname" 
            :formatter="formatter"
            width="220"></el-table-tree-column>
  • with scopedSolts
<el-table-tree-column 
            file-icon="icon icon-file" 
            folder-icon="icon icon-folder" 
            prop="label" 
            label="labelname" 
            width="220">
    <template slot-scope="scope">
        <span>prefix =></span>
        <span>{{scope.row.label}} -- {{scope.row.id}}</span> 
        <span><= suffix</span>   
    </template>
</el-table-tree-column>

element-tree-grid's People

Contributors

foolishchow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

element-tree-grid's Issues

打包报错

我在Vue项目的main.js中如下引入:
import ElTreeGrid from 'element-tree-grid'
import ElTableTreeColumn from 'element-tree-grid/src/index.js'
Vue.component(ElTreeGrid.name, ElTreeGrid)

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
el: '#app',
router,
ElTableTreeColumn,
template: '',
components: {
app
}
})
在npm run build的时候报错:如下:
ERROR in static/js/vendor.7887f3a6d40d515f31fd.js from UglifyJs
Unexpected token: punc (() [./~/.0.0.15@element-tree-grid/src/table-column.js:3,0][static/js/vendor.7887f3a6d40d515f31fd
.js:14339,14]

node data ara loaded repeated

When I use the remote loading child node, multiple clicks on the child node data are repeated.

template:

<el-table-tree-column :remote="remote" :expand-all="!!1" file-icon="icon icon-file" folder-icon="icon icon-folder" prop="id" label="ID"></el-table-tree-column>

javascript:

    remote(row, callback) {
            this.get('/codebook/sub/' + row.id, result => {
                var data = [];
                result.data.codes.forEach(item=>{
                    data.push(item);
                })
                callback(data);
            })
        }

除了remote,至少提供同步返回数据值的方式

remote(row,callback){
            setTimeout(function() {
                callback(row.children)
            },500)
        }

如果我不用setTimeout,那么就出错了。比如

remote(row,callback){
           callback(row.children)
        }

这样也不行。

所以,这个有点不好。

此外,如果使用el-dialog弹出,因为异步的方式,往往table的高度计算有问题。

修改间距

我如何修改第一层子元素和父元素就有一个间隔差呢?类似element-ui里面的tree组件那样的间距表现形式

My element tree grid is not work

I use this plugin but not work.
Is there some mistake with me?

 el-table(:data="dimensions")
        el-table-tree-column(label="test", :remote="load_child_dimension")
        el-table-column(label="definition" prop="definition")
        el-table-column(label="rule" prop="rule")
        el-table-column(label="tableName" prop="tableName")
//-....
//....
methods: {
    load_child_dimension(row, cb){
      let p = { params: { parentId: row.id } }
       this.$http.get("/data/indexsystem/dimension/sublist", p).then(r=>{
        row.children = r.body.datas
        cb(row.children)
      })
    },
}

异步请求,无法插入DOM

e pphh 8_3nmh 99knuqfpj

Car Gps & AccessoriesCarLightschildren 都是异步请求的
如果不点击展开的话 两个都可以正常插入 各自的 children

但是!!!!

3_0yttt81bockg_xo o vwf

如果 我点击展开某一项的话 另外一项就无法插入 children
数据是有改变的!!

Row does not match index

When i default to open level3,the parameters of the method(doexpanded) is wrong,row does not match index,so when it open the tree,children is wrong.Maybe row[vm.childKey] can change to prefix[prefix.length-1][vm.childKey]

line click

how do deal with line click event?...if i click a row ..this table children will expand.

父子层级间距问题

目前父子层级都是靠左对其,如何让子层级相对父层级靠右一个单位,类似element-ui的树形展示方式。

关于正确获取row.expanded

楼主大大您好.
之前使用您这个插件(el-tree-grie:v0.0.15, el-ui:v1.4.6),触发talbe的rowClick事件时,可以返回正确的row.$extra.expanded。
后来升级了el-ui:v2.3.3,再次获取row.$extra.expanded就不正确了。
再次升级el-tree-grie:v0.1.3,获取row中已经没有$extra了。
请问我该如何获取当前row的正确的expanded状态?

v0.0.12 still have repeated bug, and wrong hierarchy

On 0.0.12 version, i found still have repeated bug, and wrong hierarchy.
And if i use element el-tree , everything is ok. So i guess the data is valid.

My tree data json is here:
[ { "id": 1, "label": "root", "value": { "data": [ { "name": "gm", "age": 19, "hobby": { "aa": 11, "bb": 22 } } ], "state": 0 }, "remark": "", "type": "object", "oriType": "object", "children": [ { "id": 2, "label": "data", "value": [ { "name": "gm", "age": 19, "hobby": { "aa": 11, "bb": 22 } } ], "remark": "", "type": "array<object>", "oriType": "array<object>", "subType": "object", "children": [ { "id": 4, "label": "name", "value": "gm", "remark": "", "type": "string", "oriType": "string", "children": [] }, { "id": 5, "label": "age", "value": 19, "remark": "", "type": "number", "oriType": "number", "children": [] }, { "id": 6, "label": "hobby", "value": { "aa": 11, "bb": 22 }, "remark": "", "type": "object", "oriType": "object", "children": [ { "id": 7, "label": "aa", "value": 11, "remark": "", "type": "number", "oriType": "number", "children": [] }, { "id": 8, "label": "bb", "value": 22, "remark": "", "type": "number", "oriType": "number", "children": [] } ] } ] }, { "id": 9, "label": "state", "value": 0, "remark": "", "type": "number", "oriType": "number", "children": [] } ] } ]

我也遇到了打包报错问题

vue组件
`import ElTableTreeColumn from 'element-tree-grid/src/index.js'

export default {
name: '',
components: {
ElTableTreeColumn
},
data () {
return {
tableData: [],
searchForm: {}
}
},
computed: {},
created () {
this.loadMenu()
},
methods: {
loadMenu () {
this.axios.get('/brandhall/setting.menu/getlist').then(res => {
this.tableData = res
})
},
addMenu () {
this.$router.push('add')
},
editMenu (id) {
this.$router.push('edit/' + id)
},
deleteMenu (id) {
this.$confirm('您确定要删除该菜单吗?', '提示', {
type: 'warning'
}).then(() => {
this.axios.post('/brandhall/setting.menu/delete', {id: id}).then(res => {
this.loadMenu()
})
}, () => {})
}
}
}`
路由使用的懒加载

babel配置
{ "presets": [ ["env", { "modules": false }], "stage-2" ], "plugins": ["transform-runtime",["component", [ { "libraryName": "element-ui", "styleLibraryName": "theme-default" }, { "libraryName": "element-tree-grid" }, { "libraryName": "vue-qrcode" } ]]], "comments": false, "env": { "test": { "presets": ["env", "stage-2"], "plugins": [ "istanbul" ] } } }

打包总是报错,
Unexpected token: punc (() [./~/_element-tree-grid@0.0.15@element-tree-grid/src/table-column.js:3,0][static/js/8.3f0de3281e3c143d7485.js:230,14]
请问下怎么解决啊

Remote never called

All data are objects(not your format, simular to ORM on sqlalchemy), so i cannot set "prop".
And "remote" method never called, set "allRemote" does not help me

expandAll

设置expandAll为true,第一次加载数据时表格是展开的,但第二次加载数据表格没有展开

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.