Css styles overwrite

Hello.
I understand that I mismatch something importnat, but I can’t overwrite css classes for table properly.
I use handsontable with vue wrapper.
When I redefine style for “hansontable” class in my css, then I see it on dom, but (I’m not sure) priority of my styles are less than native. What interest that “ht_master” style is redefining success.
Styles like this:

.handsontable {
    height: 100%;
}

.wtHolder {
    height: 100%;
}

.ht_clone_left handsontable {
    height: 100%;
}

I want to set all elements height in percents, not in pixels (it breaks my layout, table size should be dynamic)

Html:

<HotTable 
  :root="id"
  :settings="job"
  :manualColumnResize="true"
  :manualRowResize="true">
</HotTable>

How to do css redefining right?

Thanks.

Hi @alikin.sergey

Can we close this issue as we already discussed percentages at Set (change) text value for corner cell?

@aleksandra_budnik, unfortunately I’m not sure that I see solution for this problem.
May be you show me a typical boilerplate for overwriting css styles in table and I will looking for mistake by myself?
I tried to replace className prop, tried to use element.id, but my styles are still not active (styles from your documentation for changing header colors, for example).
Thanks.

All the elements have to provides in pixels. What you can do (as a workaround) to attach an event that will check if a user resizes windows and change the pixel values.

@aleksandra_budnik, thanks. I have suspected something similar. I will use resizr event handler.
But the main qustion: why I can’t set my own styles for ‘handsontable’ class? This is even more important that pixels.

May be I was not accurate.
My main problem that any examples from your guide (https://docs.handsontable.com/0.38.0/tutorial-styling.html#page-table) are not working, only ht_master class styles are affected.

Sorry. It looks like I do not understand the request.

What I can add right now is the fact that here https://docs.handsontable.com/0.38.0/tutorial-styling.html we do the simple stuff

/* All headers */
.handsontable th {
  background-color: #F00;
}

/* Row headers */
.ht_clone_left th {
  background-color: #F00;
}

/* Column headers */
.ht_clone_top th {
  background-color: #F00;
}

that results in this

But setting up dimensions do not always is handled by CSS (in Handsontable). Some of the operations are recalculated after table gets initialization settings and then it rerenders using hardcoded height/width pixel values.

By adding the fact that Handsontable has a layer structure and some of the elements are hidden under other elements it gets really hard to parse the values to percentages.

Maybe it would be easier if you could share a demo and I’ll check if anything can be done. What do you think about that?

@aleksandra_budnik, I will try to do minimal working snippet (vue + hands) with jsfiddle.

@aleksandra_budnik, I don’t see this problem with raw js, styles are working as expected.
I used demo application from your vue wrapper repository and found that problem behavior could reproduce this app. Unfortunately, your code is not working out-of-box (container names are differ in js and vue files, vue instance have no link to component template), I fixed it a little, also it contains problematic styles (handsontable).
Also I think it can be depends on this problem: https://github.com/handsontable/vue-handsontable-official/pull/32, because I also edited HotTable.vue file.
Version info:
“handsontable”: “^0.35.1”,
“vue”: “^2.5.16”,
“vue-handsontable-official”: “^1.1.0”,

I hope this information help us to solve this problem.

index.js:

/* eslint-disable */

import Vue from 'vue';
import SampleApp from './sampleApp.vue';

Vue.component('sampleapp', SampleApp);

new Vue({
  el: '#app',
  template: '<sampleapp/>'
});

sampleApp.Vue:

<template>
  <div id="app" class="wrapper">
    <div id="hot-options">
      <label v-on:click="toggleOption" for="fixed-rows"><input id="fixed-rows" type="checkbox"/>Add fixed
        rows</label><br/>
      <label v-on:click="toggleOption" for="fixed-columns"><input id="fixed-columns" type="checkbox"/>Add fixed columns</label><br/>
      <label v-on:click="toggleOption" for="row-headers"><input id="row-headers" type="checkbox"/>Enable row
        headers</label><br/>
      <label v-on:click="toggleOption" for="column-sorting"><input id="column-sorting"
                                                                   type="checkbox"/>Enable sorting</label><br/>
      <label v-on:click="toggleOption" for="column-resize"><input id="column-resize" type="checkbox"/>Enable column resizing</label><br/>
    </div>
    <div id="hot-preview">
      <HotTable :root="root" :settings="hotSettings"></HotTable>
    </div>
  </div>
</template>

<script>
/* eslint-disable */
  import HotTable from 'vue-handsontable-official';
  import Vue from 'vue';
  export default {
    data: function() {
      return {
        root: 'test-hot',
        hotSettings: {
          data: function(rows, columns) {
            const result = [];
            for (let i = 0; i < rows; i++) {
              let row = [];
              for (let j = 0; j < columns; j++) {
                row.push('[' + i + ', ' + j + ']');
              }
              result.push(row);
            }
            return result;
          }(40, 40),
          colHeaders: true
        }
      };
    },
    methods: {
      toggle: function(input, property, onValue, offValue) {
        if (onValue === void 0) {
          onValue = true;
        }
        if (offValue === void 0) {
          offValue = false;
        }
        if (input.checked) {
          Vue.set(this.hotSettings, property, onValue);
        } else {
          Vue.set(this.hotSettings, property, offValue);
        }
      },
      toggleOption: function(event) {
        if (event.target.tagName.toLowerCase() !== 'input') {
          return false;
        }
        switch (event.target.id) {
          case 'fixed-rows':
            this.toggle(event.target, 'fixedRowsTop', 3, 0);
            break;
          case 'fixed-columns':
            this.toggle(event.target, 'fixedColumnsLeft', 3, 0);
            break;
          case 'row-headers':
            this.toggle(event.target, 'rowHeaders');
            break;
          case 'column-sorting':
            this.toggle(event.target, 'columnSorting');
            break;
          case 'column-resize':
            this.toggle(event.target, 'manualColumnResize');
            break;
        }
      }
    },
    name: 'SampleApp',
    components: {
      HotTable
    }
  }
</script>

<style>
.handsontable th {
  background-color: #F00;
}
.ht_master tr:nth-of-type(odd) > td {
  background-color: #f00;
}
  #example-container {
    position: relative;
  }
  #hot-options {
    width: 200px;
    position: absolute;
    top: 0;
    left: 0;
    padding: 15px;
    font-size: 14px;
  }
  #hot-preview {
    margin-left: 220px;
  }
  #test-hot {
    width: 600px;
    height: 400px;
    overflow: hidden;
  }
</style>

Sorry @alikin.sergey

I forgot about this issue. Have you had some time to check what can cause this issue? So, it looks like the Vue wrapper can cause it?

@aleksandra_budnik, don’t worry.
I will work with handsontable issues at this weekend, so, yes, I will check vue wrapper and inform you about results.

@aleksandra_budnik, also I want to ask: my other theme (Set (change) text value for corner cell) was closed. But I found small (and unpleasant) bug. Where I can post this information? Thanks.

Hi @alikin.sergey

if the new issue relates to Handsontable CE you can post it on the CE Github board github.com/handsontable/handsontable and if it is for PRO feature that you can post it here/just on a new topic.