@@ -20,6 +20,8 @@ export class GridCoreComponent {
2020 * @property {boolean } [showFilters=false] - Show filters button to open filters
2121 * @property {boolean } [showSettings=false] - Show settings button to customize columns
2222 * @property {boolean } [showSerialNumberCol=false] - Show serial number column
23+ * @property {string } [theme=light] - Default available themes are light and dark. But you could define custom themes and use here.
24+ * @property {string } [language=default] - Language name to get i18n text
2325 * @property {string } [tooltipFontSize=14px] - Font size for tooltip
2426 * @property {string } [tooltipAlignment=center] - CSS Text alignment for tooltip
2527 * @property {string } [tooltipEnterDelay=300] - Delay time before showing tooltip (in milliseconds)
@@ -78,7 +80,7 @@ export class GridCoreComponent {
7880
7981 /** render methods - start */
8082 render ( ) {
81- let html = `<div class="grid-comp-wrapper" data-unique-id="${ this . uniqueId } ">
83+ let html = `<div class="grid-comp-wrapper grid-comp-theme- ${ this . theme } " data-unique-id="${ this . uniqueId } ">
8284 <div class="grid-comp-header grid-comp-hide"></div>
8385
8486 <div class="grid-comp-filters-tags-wrapper">
@@ -1417,6 +1419,8 @@ export class GridCoreComponent {
14171419 this . perPageOptions = options . perPageOptions ;
14181420 this . uniqueKey = options . uniqueKey ;
14191421 this . apiUrl = options . apiUrl ;
1422+ this . theme = options . theme . toLowerCase ( ) ;
1423+ this . language = options . language . toLowerCase ( ) ;
14201424 this . scrollableContent = convertToBoolean ( options . scrollableContent ) ;
14211425 this . rowsFromServer = convertToBoolean ( options . rowsFromServer ) ;
14221426 this . resizable = convertToBoolean ( options . resizable ) ;
@@ -1461,6 +1465,8 @@ export class GridCoreComponent {
14611465 disableLocalstorage : false ,
14621466 showSerialNumberCol : false ,
14631467 perPageOptions : [ 25 , 50 , 100 ] ,
1468+ theme : 'light' ,
1469+ language : 'default' ,
14641470 tooltipFontSize : '14px' ,
14651471 tooltipAlignment : 'center' ,
14661472 tooltipEnterDelay : 200 ,
@@ -1485,6 +1491,8 @@ export class GridCoreComponent {
14851491 'data-show-settings' : 'showSettings' ,
14861492 'data-disable-localstorage' : 'disableLocalstorage' ,
14871493 'data-show-serial-number-col' : 'showSerialNumberCol' ,
1494+ 'data-theme' : 'theme' ,
1495+ 'data-language' : 'default' ,
14881496 'data-tooltip-font-size' : 'tooltipFontSize' ,
14891497 'data-tooltip-alignment' : 'tooltipAlignment' ,
14901498 'data-tooltip-enter-delay' : 'tooltipEnterDelay' ,
@@ -1505,7 +1513,14 @@ export class GridCoreComponent {
15051513 }
15061514
15071515 setI18n ( ) {
1508- this . i18nData = i18n [ 'default' ] ;
1516+ let language = this . language ;
1517+ let i18nData = Object . assign ( { } , i18n . default ) ;
1518+
1519+ if ( language !== 'default' ) {
1520+ i18nData = Object . assign ( i18nData , i18n [ language ] ) ;
1521+ }
1522+
1523+ this . i18nData = i18nData ;
15091524 }
15101525
15111526 setColumns ( columns = [ ] ) {
@@ -1815,6 +1830,20 @@ export class GridCoreComponent {
18151830 DomUtils . toggleClass ( this . $wrapper , 'has-left-column' , hasLeftColumn ) ;
18161831 DomUtils . toggleClass ( this . $wrapper , 'has-right-column' , hasRightColumn ) ;
18171832 }
1833+
1834+ setTheme ( themeName ) {
1835+ if ( ! themeName ) {
1836+ return ;
1837+ }
1838+
1839+ themeName = themeName . toLowerCase ( ) ;
1840+ let oldThemeClass = 'grid-comp-theme-' + this . theme ;
1841+ let themeClass = 'grid-comp-theme-' + themeName ;
1842+ this . theme = themeName ;
1843+
1844+ DomUtils . removeClass ( this . $wrapper , oldThemeClass ) ;
1845+ DomUtils . addClass ( this . $wrapper , themeClass ) ;
1846+ }
18181847 /** set methods - end */
18191848
18201849 /** get methods - start */
@@ -1865,6 +1894,7 @@ export class GridCoreComponent {
18651894 'data-tooltip-alignment' : this . tooltipAlignment ,
18661895 'data-tooltip-ellipsis-only' : ellipsisOnly ,
18671896 'data-tooltip-allow-html' : allowHtml ,
1897+ 'data-tooltip-additional-classes' : `grid-comp-tooltip grid-comp-theme-${ this . theme } ` ,
18681898 } ;
18691899
18701900 return DomUtils . getAttributesText ( data ) ;
@@ -2297,9 +2327,27 @@ export class GridCoreComponent {
22972327 return config . GridCoreVersion ;
22982328 }
22992329
2300- static onResizeMethod ( ) {
2330+ static getAllInstances ( ) {
2331+ let instances = [ ] ;
2332+
23012333 document . querySelectorAll ( '.grid-comp-wrapper' ) . forEach ( ( $ele ) => {
2302- $ele . gridComp . onResize ( ) ;
2334+ if ( $ele . gridComp ) {
2335+ instances . push ( $ele . gridComp ) ;
2336+ }
2337+ } ) ;
2338+
2339+ return instances ;
2340+ }
2341+
2342+ static onResizeMethod ( ) {
2343+ GridCoreComponent . getAllInstances ( ) . forEach ( ( gridComp ) => {
2344+ gridComp . onResize ( ) ;
2345+ } ) ;
2346+ }
2347+
2348+ static setTheme ( themeName ) {
2349+ GridCoreComponent . getAllInstances ( ) . forEach ( ( gridComp ) => {
2350+ gridComp . setTheme ( themeName ) ;
23032351 } ) ;
23042352 }
23052353 /** static methods - end */
0 commit comments