Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
45
Cell Style from string
posted

hi, i'm trying to pass a string in the column using the [cellStyles] property but i get a css error. "SyntaxError: Unexpected token ( in JSON at position 69".

this is my string: 


{"background": "linear-gradient(to right, #8ca6db, #b993d6)","color":(rowData, coljey, cellValue, rowIndex) => rowIndex % 2 === 0 ? "gray" : white"}; 


and this is the function that I use to send the value of the css to [cellStyles] :

public applyCSS() {
  
        var splitted = this.field.grid.cellStyles.split(";");
        
        splitted.forEach(element => {                
            if (element!=null && element!='') {
                    var css= element.trim();            
                    
                        try {
                            var style = JSON.parse(css);
                            console.log(style);
                            this.field.headerGrid.forEach((column, index) => {
                                column.cellStyles = style;
                            });
                        } catch (error) {
                            console.log(error);
                            return false;
                        }

            }
        });

        
    }


What should I do to correctly send that string in [cellStyles]?