4 issues with the grid

Hi

1. Header text alignment: when textAlign="center", the header is also centered but because of the additional filter icon, it looks a bit off to the left when expanding/resizing the column to be wider.

2. Double clicking the edge of a header auto size it based on the content, most of the time it works but sometimes the user needs to be very precise in the double click position in order for it to happen.

3. Freezecols and horizontal scrollbar: I read about the breaking changes but I didn't understand what am I suppose to do with it. In my case, When I have 2 freeze cols and a horizontal bar, the whole content of the grid doesn't appear, I see only headers and footer. If I set freezeCols to 0, everything shows up. Another grid with FreezeCols but without a horizontal scrollbar, works ok. I'm not sure it is related to the scrollbar, it's just a guess. Am I missing something here?

4. I have the following code in order to color the value conditionally
            var customAggregate = footerAggregate.contentTable.querySelector(".custom-aggregate");
            if (customAggregate) {
                var customAggregateVal = customAggregate.innerText.replace(this.getThousandSeparator().thousand"").replace(this.getCurrencySymbol(), "");
                if (Number(customAggregateVal) > 0customAggregate.classList.add("valUpPortfolio");
                else if (Number(customAggregateVal) < 0customAggregate.classList.add("valDownPortfolio");
            }

I have 3 footers that are custom so it always go with the first one and not with the other 2 values. How can I set the same condition to
all custom values I have in the footer?

Thanks

9 Replies 1 reply marked as answer

VS Vignesh Sivagnanam Syncfusion Team December 29, 2020 02:13 PM UTC

Hi Amos, 
 
Sorry for the late reply 

Query 1 : Header text alignment 

For the above query we have prepared a sample and we also faced the same issue at our end. So, please confirm with the below screenshot and confirm this is the issue that you faced at your end. 

Screenshot : 
 
 
Query 2 : Double clicking the edge of a header auto size 

Based on your query we understand that you have facing difficulties on autofit the column when we double click the column right border. So, we have prepared a sample but we are not able to reproduce the reported issue at our end. Please refer the below Video Demonstration for your reference. 


Query 3 : Freezecols and horizontal scrollbar: 

For the above query we have prepared a sample but we are unable to reproduce the issue at our end. For your convenience we have attached the sample and please find the sample from the below link 


Query 4 : color the value of aggregate 

Based on your query, you want to color the multiple aggregate value in the grid’s footer. So, we have prepared the sample and customize the aggregate value. Please refer the below Sample and Screenshot for your reference, 


Screenshot : 
 

Regards 
Vignesh Sivagnanam 



AM Amos December 29, 2020 04:44 PM UTC

Hi there

1. Yes, this is exactly it.

2. It happens with your demo: https://codesandbox.io/s/crazy-boyd-c6pys?file=/src/App.vue . Resize down Order Id column and then double click the border between Order Id and Employee Id. If I resize it down a bit, it works but resizing it further (making it narrow), the double click is not automatically resize back the column.

3. The problem seems to be related to a class I'm adding to the surrounding div of the grid
<div :class="getGridClass()">
            <ejs-grid
                :frozenColumns="2"...
</ejs-grid>


getGridClass() {
            if (this.$q.platform.is.mobilereturn "itemsPanelMobile";
            else return "itemsPanelDesktop";
        },


.itemsPanelDesktop {
    heightcalc(100vh - 110px);
    margin-top10px;
}

The purpose is to match the grid's height to the remaining of the window's height and the grid to show its inner vertical scrollbar
for the content. It worked very well until 2-3 versions ago and now it makes the content height as 1px causing it to be hidden which is
weird because the div is outside of the grid itself. If I remove this class, the content is visible but the height of the grid is per its
content without a vertical scrollbar. All the above is ONLY when frozen columns > 0.

4. Not sure I understand your solution. I have several aggregation fields. Several are sum for specific columns and 3 are custom.
Based on a previous response I got from you, I did the following in onDataBound

var footerAggregate = this.$refs.gridObj.ej2Instances.aggregateModule.footerRenderer;
            if (!footerAggregate.aggregates.aggregatesreturn;
            if (footerAggregate.aggregates.aggregates["pl - sum"] > 0) {
                footerAggregate.contentTable
                    .querySelector(".sumPL-aggregate")
                    .closest(".e-templatecell")
                    .classList.add("valUpItems");
            } else if (footerAggregate.aggregates.aggregates["pl - sum"] < 0) {
                footerAggregate.contentTable
                    .querySelector(".sumPL-aggregate")
                    .closest(".e-templatecell")
                    .classList.add("valDownItems");
            }
            if (footerAggregate.aggregates.aggregates["market - sum"] > footerAggregate.aggregates.aggregates["cost - sum"]) {
                footerAggregate.contentTable
                    .querySelector(".sumMarket-aggregate")
                    .closest(".e-templatecell")
                    .classList.add("valUpItems");
            } else if (footerAggregate.aggregates.aggregates["market - sum"] < footerAggregate.aggregates.aggregates["cost - sum"]) {
                footerAggregate.contentTable
                    .querySelector(".sumMarket-aggregate")
                    .closest(".e-templatecell")
                    .classList.add("valDownItems");
            }
            var customAggregate = footerAggregate.contentTable.querySelector(".custom-aggregate");
            if (customAggregate) {
                var customAggregateVal = customAggregate.innerText.replace(this.getThousandSeparator().thousand"").replace(this.getCurrencySymbol(), "");
                if (Number(customAggregateVal) > 0customAggregate.classList.add("valUpItems");
                else if (Number(customAggregateVal) < 0customAggregate.classList.add("valDownItems");
            }

While the column specific aggregators have specific identifier like market - sum, so the coloring is done correctly, the custom ones do not
have unique identifier so the last "if condition" above is catching only the first one. I need the custom aggregation to either have a
unique identifier or the custom aggregators to somehow loop all custom aggregators instead of "catching" only the first one.

Thanks



SK Sujith Kumar Rajkumar Syncfusion Team December 31, 2020 12:57 PM UTC

Hi Amos, 
 
Please find the response for your queries below, 
 
Query: “Yes, this is exactly it. 
 
Thanks for the update. 
 
We validated this case further and would like to let you know that since the center alignment is calculated from the start till the filter icon position, the header text position appears to be moved to the left. 
 
Since your requirement is to align the header text center without considering the filter icon, you can achieve the same by applying the following styles to the Grid’s header div element, 
 
<style> 
.e-headercelldiv { 
  padding: 0 !important; 
  margin-left: 0 !important; 
  margin-right: 0 !important; 
} 
</style> 
  
Please find the sample prepared based on this for your reference below, 
 
 
Query: “Vertical scrollbar not displayed with frozen columns when using certain css styles” 
 
We checked this case with your provided code snippet but still could not reproduce it from our end. Please check the below updated sample for your reference, 
 
 
We suspect you might be facing the problem due to cached memory in the browser which could be restoring the old settings. So please clear the browse cache, run the above sample and ensure if this case is working fine. Also try opening it in other browsers. 
 
If problem still persists please share us the following details to validate further on this, 
 
  • Browser and its version in which you were able to reproduce the problem.
  • Video demonstration of the problem.
  • Syncfusion package version used.
  • If possible share us a simple sample to replicate the problem or try reproducing it in the above provided sample.
 
Query: “I need the custom aggregation to either have a unique identifier or the custom aggregators to somehow loop all custom aggregators instead of "catching" only the first one. 
 
Based on this query we could understand that your requirement is to differentiate/loop through all the custom aggregates element which we suspect you are accessing by defining custom class through the footerTemplate function. The steps for achieving the same are explained below, 
 
By differentiating, we suspect you need to access the corresponding column information for the aggregate cell. If so you can achieve it by passing the unique column id that is set as the aggregate ‘td’ element’s ‘e-mappinguid’ to the Grid’s getColumnByUid method as shown in the below image, 
 
 
 
You can also loop through all the custom-aggregate elements, check condition for them and apply styles by retrieving all the elements using JavaScript’s “querySelectorAll” method as demonstrated in the below code snippet, 
 
// Grid’s dataBound event handler 
onDataBound: function (args) { 
     // This event will be triggered each time the grid data is modified, so flag variable is used so that this case is executed only on Grid initial render 
    if (this.initialFlag) { 
        var gridObj = this.$refs.grid.ej2Instances; 
        // All the custom aggregate elements are retrieved with its class name using ‘querySelectorAll’ 
        var customAgg = gridObj.aggregateModule.footerRenderer.contentTable.querySelectorAll(".custom-aggregates"); 
        var i = 0; 
        // The custom aggregate value is compared and custom CSS is added based on that 
        while (i < customAgg.length) { 
            var Val = parseInt(customAgg[i].innerText); 
            if (Val > 10) { 
                customAgg[i].classList.add("custom-css"); 
            } else { 
                customAgg[i].classList.add("customize-css"); 
            } 
            i++; 
        } 
        this.initialFlag = false; 
    } 
} 
 
Please find the below updated sample prepared based on this for your reference, 
 
 
More details on this can be checked in the below documentation link, 
 
 
 
Let us know if you have any concerns. 
 
Regards, 
Sujith R 



SK Sujith Kumar Rajkumar Syncfusion Team December 31, 2020 12:58 PM UTC

Hi Amos, 
 
Please find the response for your queries below, 
 
Query: “Yes, this is exactly it. 
 
Thanks for the update. 
 
We validated this case further and would like to let you know that since the center alignment is calculated from the start till the filter icon position, the header text position appears to be moved to the left. 
 
Since your requirement is to align the header text center without considering the filter icon, you can achieve the same by applying the following styles to the Grid’s header div element, 
 
<style> 
.e-headercelldiv { 
  padding: 0 !important; 
  margin-left: 0 !important; 
  margin-right: 0 !important; 
} 
</style> 
  
Please find the sample prepared based on this for your reference below, 
 
 
Query: “Vertical scrollbar not displayed with frozen columns when using certain css styles” 
 
We checked this case with your provided code snippet but still could not reproduce it from our end. Please check the below updated sample for your reference, 
 
 
We suspect you might be facing the problem due to cached memory in the browser which could be restoring the old settings. So please clear the browse cache, run the above sample and ensure if this case is working fine. Also try opening it in other browsers. 
 
If problem still persists please share us the following details to validate further on this, 
 
  • Browser and its version in which you were able to reproduce the problem.
  • Video demonstration of the problem.
  • Syncfusion package version used.
  • If possible share us a simple sample to replicate the problem or try reproducing it in the above provided sample.
 
Query: “I need the custom aggregation to either have a unique identifier or the custom aggregators to somehow loop all custom aggregators instead of "catching" only the first one. 
 
Based on this query we could understand that your requirement is to differentiate/loop through all the custom aggregates element which we suspect you are accessing by defining custom class through the footerTemplate function. The steps for achieving the same are explained below, 
 
By differentiating, we suspect you need to access the corresponding column information for the aggregate cell. If so you can achieve it by passing the unique column id that is set as the aggregate ‘td’ element’s ‘e-mappinguid’ to the Grid’s getColumnByUid method as shown in the below image, 
 
 
 
You can also loop through all the custom-aggregate elements, check condition for them and apply styles by retrieving all the elements using JavaScript’s “querySelectorAll” method as demonstrated in the below code snippet, 
 
// Grid’s dataBound event handler 
onDataBound: function (args) { 
     // This event will be triggered each time the grid data is modified, so flag variable is used so that this case is executed only on Grid initial render 
    if (this.initialFlag) { 
        var gridObj = this.$refs.grid.ej2Instances; 
        // All the custom aggregate elements are retrieved with its class name using ‘querySelectorAll’ 
        var customAgg = gridObj.aggregateModule.footerRenderer.contentTable.querySelectorAll(".custom-aggregates"); 
        var i = 0; 
        // The custom aggregate value is compared and custom CSS is added based on that 
        while (i < customAgg.length) { 
            var Val = parseInt(customAgg[i].innerText); 
            if (Val > 10) { 
                customAgg[i].classList.add("custom-css"); 
            } else { 
                customAgg[i].classList.add("customize-css"); 
            } 
            i++; 
        } 
        this.initialFlag = false; 
    } 
} 
 
Please find the below updated sample prepared based on this for your reference, 
 
 
More details on this can be checked in the below documentation link, 
 
 
 
Let us know if you have any concerns. 
 
Regards, 
Sujith R 



AM Amos December 31, 2020 02:32 PM UTC

Hi

1. Centering headers: Thanks

2. double clicking the border of a header: you missed this point in your last reply, here is my last reply about this issue: It happens with your demo: https://codesandbox.io/s/crazy-boyd-c6pys?file=/src/App.vue . Resize down Order Id column and then double click the border between Order Id and Employee Id. If I resize it down a bit, it works but resizing it further (making it narrow), the double click is not automatically resize back the column.

3. Can we do a web meeting about this?

4. custom aggregation loop: works, just a small typo
var customAgg = gridObj.aggregateModule.footerRenderer.contentTable.querySelectorAll(".custom-aggregate");
instead of
var customAgg = gridObj.aggregateModule.footerRenderer.contentTable.querySelectorAll(".custom-aggregates"); 
.custom-aggregate - should be without the last S

Thanks


VS Vignesh Sivagnanam Syncfusion Team January 4, 2021 01:48 PM UTC

Hi Amos 

Thanks for the update 

Query : double clicking the border of a header doesn’t autofit 

Based on query we have understand that you have facing the issue while clicking the border of the header to autofit. From your query, we have reproduced the reported an issue at our end. To resolve the reported issue at our end and we suggest to use the below solution to overcome the reported problem. Please review the below code example and sample for more information. 

Code Example :  
load: function (args) { 
      var newResizeStart = this.$refs.grid.ej2Instances.resizeModule 
        .resizeStart; 
      this.$refs.grid.ej2Instances.resizeModule.resizeStart = function (e) { 
        if (!Global.timer) { 
          Global.timer = setTimeout(function () { 
            Global.timer = null; 
          }, 300); 
          return newResizeStart.apply(this, [e]); 
        } else { 
          clearTimeout(Global.timer); 
          Global.timer = null; 
          this.callAutoFit(e); 
        } 
     }; 
    }, 

Please refer the below Sample For your reference, 


Regards 
Vignesh Sivagnanam 



AM Amos January 4, 2021 02:05 PM UTC

* double clicking the border of a header doesn’t autofit

Even if it will work, isn't it something that should be fixed via the code of the component?
I admit that I don't like adding code and global timers and logic into this to make it work.
Any reason why it happens in the first place? It looks like it's working in general except for specific scenarios.

Thanks


VS Vignesh Sivagnanam Syncfusion Team January 5, 2021 02:05 PM UTC

Hi Amos 

Thanks for your patience 

We have validated your reported query at our end. We have considered this as a bug in Grid component “Column autofit not working properly for certain cases when double clicking the resize bar”. At Syncfusion, we are committed to fixing all validated defects (subject to technological feasibility and Product Development Life Cycle ) and will include the defect fix in our upcoming weekly patch release on 20th January 2020. 

You can track the below link for status of this issue fix.   
    
    
We appreciate your patience.   
   
Regards,    
Vignesh Sivagnanam 



RR Rajapandi Ravi Syncfusion Team January 21, 2021 12:18 PM UTC

Hi Amos, 

We are glad to announce that our Essential Javascript2 patch release (v 18.4.35) has been rolled out successfully and in that release we have added the fix for “Column autofit not working properly for certain cases when double clicking the resize bar” issue. So please update your package to this version to include the fix. 



We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance. 
 
Regards,            
Rajapandi R 


Marked as answer
Loader.
Up arrow icon