I have a kendo UI grid with many columns. Columns that overflow can be viewed by scrolling horizontally. However, if you
1) scroll to a column that is not initially displayed and
2) filter on that column such that no rows match the filter criteria
the grid will no longer allow scrolling horizontally. The column that had the filter applied cannot be cleared.
How can I show the horizontal scrollbar after such filtering?
Here's a jsfiddle where you can see the issue
http://jsfiddle.net/9sxkG/1/
Here's the code:
var dataItem = {};
var columns = [];
for (var i = 0; i < 20; i++) {
dataItem['col' + i] = i;
columns.push( {
field: 'col' + i,
width: 80,
filterable: true,
type: 'number'
} );
}
$("#grid").kendoGrid({
scrollable:true,
columns: columns,
filterable: true,
dataSource: [dataItem]
});
For example, go to column 18 and filter on equal to 20 to see the issue.
Apply Scrollable() and give Width for each columns and then if the total width exceeds the width of the grid the horizontal scrollbar will appear.
Basic Horizontal Scroll Box To make a scroll box with a horizontal scroll, you need to use the overflow-x property. Specifically, you need to use this code: overflow-x:scroll; . This tells your browser to create scroll bars on the x (horizontal) axis, whenever the contents of the container is too wide.
scrollable Boolean|Object (default: true) If set to true the grid will display a scrollbar when the total row height (or width) exceeds the grid height (or width). By default scrolling is enabled.
To enable horizontal scrolling, we can use the CSS property overflow-x. If we assign the value scroll to the overflow-x property of the container element, the browser will hide horizontally overflowing content and make it accessible via horizontal scrolling.
I had the same problem, I solved it adding a empty row to the grid.
Code:
var dataItem = {};
var columns = [];
for (var i = 0; i < 20; i++) {
dataItem['col' + i] = i;
columns.push( {
field: 'col' + i,
width: 80,
filterable: true,
type: 'number'
} );
}
$("#grid").kendoGrid({
scrollable:true,
columns: columns,
filterable: true,
dataSource: [dataItem],
dataBound: function(e) {
if(this.dataSource.view().length == 0) {
var colspan = this.content.find("table col").length;
this.content.find("table").append("<tr><td colspan=" + colspan + "></td></tr>");
}
$("#grid").find(".k-grid-footer-wrap").scrollLeft($("#grid").find(".k-grid-content").scrollLeft());
this.content.bind('scroll', function () {
$("#grid").find(".k-grid-footer-wrap").scrollLeft(this.scrollLeft);
});
}
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With