Skip to content
This repository has been archived by the owner on Apr 1, 2022. It is now read-only.

Fixed header problems #135

Open
mhascak opened this issue Jul 3, 2018 · 15 comments
Open

Fixed header problems #135

mhascak opened this issue Jul 3, 2018 · 15 comments

Comments

@mhascak
Copy link

mhascak commented Jul 3, 2018

Hello, thanks for you work. I have some problems with fixed header behavior.
I have this grid component:

<template>
<div style="width: 100%">
        <datatable v-bind="$data" :HeaderSettings="false" tblStyle="table-layout: fixed" tblClass="table-bordered"></datatable>
</div>
</template>



<script>
    import Vue from 'vue';
    import GridComponents from '../../components/dataGrid'

    export default {
        props: ['row'],
        name: 'SettingTable',
        components: { ...GridComponents },
        methods: {
            alertSelectedUids() {
                alert(this.selection.map(({ uid }) => uid))
            },
            loadData() {
            }
        },
        data() {
            return {
                columns: [
                    { title: 'Akce', tdComp: 'Actions', fixed: true, colStyle: { width: '80px' }   , fixed: true  },
                    { title: 'Název', field: 'name', sortable: true, colStyle: { width: '200px' }  },
                    { title: 'Doporučeno?', field: 'isFeatured', tdComp: 'Check', sortable: true , colStyle: { width: '200px' } },
                    { title: 'Na zavolení', field: 'isCallForPricing', tdComp: 'Check', sortable: true, colStyle: { width: '200px' }  },
                    { title: 'K objednání', field: 'isAllowToOrder', tdComp: 'Check', sortable: true, colStyle: { width: '200px' }  },
                    { title: 'Skladem ks.', field: 'stockQuantity', sortable: true, colStyle: { width: '200px' }  },
                    { title: 'Publikováno', field: 'isPublished', tdComp: 'Check', sortable: true, colStyle: { width: '200px' }  },
                ],
                data: [
                    {uid: 1,  name: "Testovací produkt",  isFeatured: true,  isCallForPricing: true,  isAllowToOrder: false, stockQuantity:6,  isPublished: false },
                    {uid: 2,  name: "Testovací produkt 2",  isFeatured: true,  isCallForPricing: true,  isAllowToOrder: false, stockQuantity:6,  isPublished: false },
                    {uid: 3,  name: "Testovací produkt 3",  isFeatured: false,  isCallForPricing: true,  isAllowToOrder: true, stockQuantity:5,  isPublished: false },
                    {uid: 4,  name: "Testovací produkt 4",  isFeatured: true,  isCallForPricing: false,  isAllowToOrder: true, stockQuantity:2,  isPublished: false }
                ],
                fixHeaderAndSetBodyMaxHeight: 200,
                pageSizeOptions: [5, 10, 15, 20],
               // selection: [],
                //summary: {},
                total: 1,
                query: {},
                xprops: {
                    editRouteName: 'edit',
                    eventbus: new Vue() // only for current Datatable instance
                }

            }
        },
        created() {

        },
        watch: {
            query: {
                handler() {
                    this.loadData()
                },
                deep: true
            }
        },

    };

And this custom td templates:

td-Actions.vue :

<template>
    <div class="page card">
        <div class="page-header card-header">
            <slot name="page-title">
                <div class="page-title">
                    <h2>{{ pageTitle.toUpperCase() }}</h2>
                </div>
            </slot>
            <slot name="page-head-menu">
            </slot>
        </div>
        <div class="page-body card-body">
            <slot></slot>
        </div>
    </div>
</template>


<script>
export default {
    data() {
        return {
            pageTitle: this.$route.meta.title || ""
        }
    }
}

</script>

td-Check.vue :

<template>
   <i :class="icon"></i>
</template>
<script>
export default {
        props: ['value'],
        computed: {
            icon: function () {
                if (this.value == true) {
                    return "fa fa-check";
                } else {
                    return "fa fa-times";
                }
            }
        }
}
</script>

And there are 2 problems:

fixheaderbug1
fixheaderbug2

On second picture is first column < 80 px it should have fixed width: 80px. When I´m horizontaly scrolling column width change dynamically.

On 3 image is problem with heder filter menu which is displayed under the grid, so I do not see it.
fixheaderbug3

Thanks for help.

@kenberkeley
Copy link
Collaborator

kenberkeley commented Jul 3, 2018

colStyle: { width: '80px' } => thStyle: { width: '80px' }, tdStyle: { width: '80px' }

@mhascak
Copy link
Author

mhascak commented Jul 3, 2018

I updated:

{ title: 'Akce', tdComp: 'Actions',  thStyle: { width: '85px' }, tdStyle: { width: '85px' } , fixed: true  },

And I have the same problems...

@kenberkeley
Copy link
Collaborator

@mhascak
Copy link
Author

mhascak commented Jul 3, 2018

I have already set this props..

<datatable v-bind="$data" :HeaderSettings="false" tblStyle="table-layout: fixed" tblClass="table-bordered"></datatable>

But when I do it in data() there is not any difference... Your example with fixed columns have the same problems, (try disable right fixed columns and wrapped div set with: 100%)

fixheaderbug4

@mhascak
Copy link
Author

mhascak commented Jul 9, 2018

Any idea how to solve this problem ? Thanks

@kenberkeley
Copy link
Collaborator

sorry for the forgettery...

@kenberkeley
Copy link
Collaborator

if the width is enough to display all the columns, you might not need to fix some columns

@kenberkeley
Copy link
Collaborator

if you want the fixed columns look normal, you might have to increase their widths

@kenberkeley
Copy link
Collaborator

kenberkeley commented Jul 9, 2018

the magic of fixed columns is, creating new tables to cover the origin ones

@kenberkeley
Copy link
Collaborator

kenberkeley commented Jul 9, 2018

since BootStrap's table is auto-extendable, you might have to fix the whole table's width

@mhascak
Copy link
Author

mhascak commented Jul 9, 2018

Hi thanks for reply.
I looked to kendo grid fixed column solution: link

It might be better to solve fixed column that way. Show fidex colums in fixed table and do not show it in base table at all.

@kenberkeley
Copy link
Collaborator

PR is warmly welcome

@kenberkeley
Copy link
Collaborator

I no longer work for OneWay Tech, so this repo might be deprecated

@mhascak
Copy link
Author

mhascak commented Jul 13, 2018

Hi, I implemented working prototype, you can see it in my fork.

@kenberkeley
Copy link
Collaborator

cool

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants