Kendo UI Grid virtual scroll hiding some records - kendo-ui

We're using lots and lots of Kendo grids, many of which have virtual scrolling set up with a server-side data source.
Sometimes, one of them will hide records beyond the "reach" of the virtual scrollbar. We can see what's going on by using Developer Tools to make the internal scrollbar visible:
It's hard to put a finger on when this happens exactly - the bug keeps popping up in seemingly random places.
Any ideas how to narrow this down / deal with it?

Try resetting the virtual scroller in the grid onDataBound event.
onDataBound: function(evt) {
//Repaint the virtual scroll bar to make sure all rows are visible to user
var grid = evt.sender.wrapper.data("kendoGrid");
grid._rowHeight = undefined;
grid.virtualScrollable.refresh();
},
You need to do this on detail row expand and shrinks as well.

I tried virtualScrollable.refresh(), does not fully shown the hidden content, but using resize(true) works
$("#yourGridId").data("kendoGrid").virtualScrollable.refresh(); //does not fully show hidden content
$("#yourGridId").data("kendoGrid").resize(true); //works
just need to call this from all the related events (still working on identifying them)

As Telerik (more or less) points out in the docs, changes to the rowheight in a grid with virtual scrolling won't work when the grid has display: none.
We had an event handler that would hide the grid and fire an async call. On success of the async call, we were changing a value that resulted in a different rowheight (removed bold from one row).
That was enough to throw off the scrolling as pictured.

Related

Issues with tabbing between Filter Fields with Horizontal scrolling - scrolling out of sync

We have a wide grid with horizontal scrolling, with 2 frozen columns. It is very wide (over 20 columns), so the horizontal scrolling is always needed.
We are using the Filter Row option to allow the user to filter. Works well, but if the user tabs between the filter fields, an issue arises. If the user tabs to a hidden field (hidden as in having to scroll to see it), then the header will scroll to accomodate, but the body will not. Likewise, if the user is scrolled all the way to the right and tabs out of the last frozen column, the scrolling again gets out of sync.
See the following Dojo example to experience the issue yourself.​
http://dojo.telerik.com/iNONA/2
If anyone has any clue as to how to fix this issue, I'd appreciate it very much!
Thanks!
I had a simular problem, just without angluar implementation. For me the jQuery scrollLeft() method solved the problem, see (Grid data isn't align with Grid header when tabbing through header columns).
$("#example .k-grid-content").scrollLeft($("#example .k-grid-header-wrap").scrollLeft())
With that line of code I got it working in the developer console of your Dojo example to adjust the grid content to the position of the header. But the scroll event, as I implemented it on my problem, didn't work on your example. Maybe this helps you and you can adjust it with the scroll event in angular.

Grid inside Table or MainTable

I have one WWSD or one SDPanel with some attributes but between these attributes that are fixed inside a Table or directly in the MainTable I want put and Grid, the problem is that the Grid is not showed and when I put the grid its no more possible scroll in the WWSD or SDPanel, is like the Grid stuck the SDPanel more than the grid is not showed.
Anyone can help me to put the Grid and keep with all normally ?
Thx.
I assume you're targeting Android.
The issue is that Android does not natively support nested scrolling. Therefore, a GeneXus layout that contains a grid will disable the form's own scrolling (so that the grid can itself scroll).
There are two ways of resolving this issue:
Redesign the panel so that the form does not vertically exceed the size of the screen (thus, form scrolling is not necessary).
Set autogrow=true for the grid, which will resize to fit all items (and "push down" any other controls located below it). Since the grid will no longer need to scroll, the form's scroll will be enabled.

NVD3 Charts not rendering correctly in hidden tab

I am building a page which contains many charts, which are displayed one at a time depending on which tab you are looking at.
The chart in the initially active tab renders correctly. However when I click to another tab, the chart is not rendered properly.
Presumably this is because the hidden field does not have dimensions until it is made visible. In fact if I resize the window the chart will correct it's proportions, and render so that it fills the available width.
I can fix this problem by explicitly defining the chart size via css, but this defeats the responsive aspect of the charts.
Can anyone tell me how to trigger the same NVD3 event which gets activated when the window resizes? That way I can bind it to the selection of a new tab, and hopefully remedy the rendering issue.
I had the same issue (charts on multiple tabs), and this is the only thing that I could get to work.
$(function () {
$(document).on('shown.bs.tab', 'a[data-toggle="tab"]', function (e) {
window.dispatchEvent(new Event('resize'));
});
});
I have a feeling, however, that all of the charts are being re-rendered, regardless of whether they are on the active tab (visible) or in the non-selected tabs (hidden).
Does anyone know how to ensure ONLY the active chart gets resized / redrawn?
I figured out how to trigger the resize event I needed. In my case the tabs are driven by bootstrap. So I simply modified my bootstrap show tab event to trigger a page resize event as well. It's a little indirect, but it gets the job done:
jQuery('#myTab a').click(function (e) {
e.preventDefault()
jQuery(this).tab('show')
jQuery(window).trigger('resize'); // Added this line to force NVD3 to redraw the chart
})
Just add this JavaScript:
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
window.dispatchEvent(new Event('resize'));
})
hidden.bs.tab is the event that fires after a new tab is shown as per the Bootstrap docs. This code fires a resize event after each tab change.
Reason For New Answer
Vanilla Javascript is necessary for a lot of people in 2018. As a lot of frameworks and Javascript libraries that exist today do not play well with jQuery. Once upon a time answering all Javascript problems with a jQuery solution was acceptable but it is no longer feasible.
Problem
When loading C3.js or D3.js graphs, if the viewport is not actively in site during page load the graphs do not render correctly.
Example
If you type in the URL then open a new tab and then go back after your page loads.
If you refresh the page that has your graphs on it then minimize the browser and open it back up after the page has loaded.
If you refresh or go to the page with the graphs then swipe away to a new window on your computer. Then go back to the page with the graphs after they have loaded.
In all these cases your C3.js / D3.js graphs will not render correctly. Typically you will see a blank canvas. So if you were expecting a bar chart, you would see a canvas without the bars being drawn.
Background
Although I have seen this question answered I needed an answer that did NOT use jQuery. Now that we have reached the days of everything can not be fixed with jQuery I thought it seemed fit to provide a vanilla Javascript answer to this question.
My team faced the issue that the C3.js / D3.js graphs would not load if you refreshed the page and swiped away or minimized. Basically if you did not stay on the page and keep it in site till it was done loading you would not see the graphs till you resized the page again. I know this is a problem that happens to everyone using C3.js / D3.js but we are specifically using Lightning in Salesforce.
Answer
Our fix was to add this in the controller function that initializes the charts. Anyone can use this in any function they write to initialize their C3.js / D3.js graphs regardless of their stack. This is not Salesforce dependent but it does indeed work if you are facing this issue in Salesforce.
document.addEventListener('visibilitychange', () => {
console.log(document.visibilityState);
window.dispatchEvent(new Event('resize'));
});
I was facing same issue. I was using ng-show to make div hidden . Once I replaced ng-show with ng-if I am able to see graph drawn in expected behavior. Explanation:
When we use ng-show or ng-hide to make div hidden it only changes it display property but div will be in dom.
When we use ng-if div is removed from dom and again added to dom so internally it performs redraw operation on nvd3 graph too. Hence we see correct graph instead of squished one.
The event that usually triggers a redraw is the window resize event -- NVD3 doesn't use a custom event for this. You can control this yourself though; the usual definition is
nv.utils.windowResize(function() { d3.select('#chart svg').call(chart); });
(where "#chart" is the element that contains the graph). There's nothing stopping you triggering the code on another event or even just running the redraw code explicitly when you change the tab.
a more efficient approach would be to use the chart.update() method
var chart_x = nv.models.somechart()
var chart_y = nv.models.somechart()
..... show charts
jQuery('#myTab a').click(function (e) {
e.preventDefault()
jQuery(this).tab('show')
if(jQuery(this)...something === '..x..')
chart_x.update(); //CALL THE UPDATE
else ...
})

Ignore events from children of a ScrollViewer while scrolling

Alright here is my issue. I have a Pivot view. Inside that pivot view a scroll viewer containing many stack panels and grids. On some of the grids I have MouseButton Up Events. What is happening is if I flick the scroll it scrolls as expected but when I release my finger most of the time it fires off the event from mousebutton up. Because technically I let up. The problem is these grids completely fill the screen so finding an area without a mousebutton up to scroll is near impossible. What I want to happen is if the user flicked to scroll I would ideally like it to ignore the mousebutton up event. It does this successfully sometimes but pretty rarely and I have noticed I have to flick pretty fast for it to work as expected.
Any ideas on how to prevent this activity. I assume there is as Listboxes work perfect.
i think u should use windows phone toolkit GestureListener to recognize flick event
I ended up setting a bool for when the scrollviewer was scrolling and based on that allowing the mouseup action to run my code. Here is the the site I used to implement the bool based on scrolling status.
http://blogs.msdn.com/b/ptorr/archive/2010/07/23/how-to-detect-when-a-list-is-scrolling-or-not.aspx

SlickGrid column headers not synched when in Full Screen mode

We have a serious problem with SlickGrid in an application.
The problem doesn't seem to have anything to do with the way we implement/built the Grid since the behavior is reproducable on every SlickGrid I've seen.
Here's the problem:
If the User is viewing a grid on less than FullScreen mode and scolls the grid horizontally, then snaps the browser to fullScreen, the column headers are out of sync with the column contents. This wouldn't be a problem if the Horz scrollbar was retained (scrolling even 1px resynch's columns/contents) but if the grid fits inside the window, there is no Horz scrollbar and no way to resynch the columns with the content.
What we need is a method to repaint the column Headers without repainting the entire grid or a patch from someone who has already solved this.
These have no effect:
Options:
syncColumnCellResize:true
Method:
grid.resizeCanvas();
Thanks...
Try the fix submitted in https://github.com/mleibman/SlickGrid/commit/c5324a130ae2ef496f2c007f736f805cc7caa3f0 (get the latest code at https://github.com/mleibman/SlickGrid/zipball/v2.0).

Resources