We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Customize cell styles in grid is not in effect

Hi,

I am trying to customize cell styles by following the example given in https://ej2.syncfusion.com/vue/documentation/grid/cell/#customize-cell-styles.


computed:{
      ...mapState({
        case_list: state => state.caseList.case_list
      }),
    },
created() {
      this.$store.dispatch('getCaseList', {id: this.$route.params.suite_id, level: 1})
    },
methods: {
      customiseCell: function(args) {
        if (args.column.field === 'case_valid') {
          console.log(args)
          if (args.data['case_valid'] === 1) {
            args.cell.classList.add('valid');
          }
          else if (args.data['case_valid'] === 0) {
            args.cell.classList.add('not-valid');
          }
        }
      }
    }



After the data is populated in grid, I can see the class of the case_valid column has valid or not-valid (shown as class="e-rowcell valid" or class="e-rowcell not-valid"), but the css style is not in effect. And the console output from console.log(args) is pointing to the cell of the last column of each row.

I wrote one sample: https://codesandbox.io/s/8np6rr2819

3 Replies

TS Thavasianand Sankaranarayanan Syncfusion Team February 14, 2019 11:41 AM UTC

Hi Jzy, 

Greetings from Syncfusion. 

We have analyzed the sample which you have shared with us. We could see that you have used “scoped” attribute for the style tag. If we remove this scoped attribute, and add !important for the styles, then style is applied fine in Grid, please refer the sample link below, 

Scoped style is applied to the elements in its initialization stage hence scoped style will not be applied for dynamically created elements and some of the columns and rows are created dynamically in Syncfusion Vue EJ2 Grid component. Please refer the official statement form Vue team in below link.  
  

We could use a custom class for the container element and use nested selectors for styling the raw HTML (Dynamically rendered elements) as a workaround for this.   
  
Please get back to us if you need further assistance. 

Regards, 
Thavasianand S. 



JZ Jzy February 18, 2019 01:59 AM UTC

Hi Thavasianand,

Thank you so much for your help, it does work.

Thanks,
Jzy


TS Thavasianand Sankaranarayanan Syncfusion Team February 18, 2019 05:33 AM UTC

Hi Jzy, 
 
We are happy that the problem has been solved. 
 
Please get back to us if you need any further assistance.  
                          
Regards, 
Thavasianand S.                         


Loader.
Live Chat Icon For mobile
Up arrow icon