5

I have implemented KendoUI in my WebApp, is there any way of making the grid responsive? Like, showing fewer columns on smaller resolutions!

Sabby62
  • 1,707
  • 3
  • 24
  • 37

7 Answers7

4

Here's my bootstrap-styled Kendo UI grid BEFORE applying the following styles

Unstyled unresponsive Kendo Grid

And here's what you get afterwards. May not be perfect, or what some will consider 'responsive' enough. But, for my users, this works a treat. Phone isn't our target platform anyways, but, now we can at least see what's in the grid, even if we cannot sort it.. etc.

enter image description here

And here are the styles inspired by @Vel's codepen, from earlier in this thread. His codepen styles are missing a statemetn to hide the colgroup element.. which is integral for this approach. Be sure to put this CSS in your page flow somewhere AFTER the main kendo CSS file

@media screen and (max-width: 800px) {

.k-widget table {
    border: 0;
}

.k-widget table thead, table colgroup {
    display: none;
}

.k-widget table tr {
    margin-bottom: 10px;
    display: block;
    border-bottom: 2px solid #ddd;
    border-radius: 20px;
}
.k-widget table tr td:last-child {
    background-color: #313444;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
}
.k-widget table tr td:nth-child(2) {
    background-color: #313444;
    color: #FFF;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    font-weight: bold;
    padding-top:1em;
}

.k-widget table td {
    display: block;
    font-size: 13px;
    border-bottom: 1px dotted #ccc;
}
.k-widget table td:before {
    content: attr(data-label);
    float: left;
    text-transform: uppercase;
    font-weight: bold;
}
}
bkwdesign
  • 1,953
  • 2
  • 28
  • 50
2

Yes. using the below link you can acheive the kenod grid responsive design.

http://codepen.io/anon/pen/QwPVNW

In media query please use like this

  @media screen and (max-width: 600px) {

   .k-grid-content > table  {
}
}
Vel
  • 194
  • 1
  • 12
2

There is now a minScreenWidth setting for each column, which hides the column when the browser width is less than the specified. In our application we have set some constants corresponding to the Bootstrap media query breakpoints, so instead of manually specifying the width every time, we use these constants and thus some columns are hidden when you are below e.g. the Bootstrap sm or xs breakpoints.

http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#configuration-columns.minScreenWidth

AsGoodAsItGets
  • 2,886
  • 34
  • 49
0

I am afraid the Grid currently does not provide you with such responsive design.

Petur Subev
  • 19,983
  • 3
  • 52
  • 68
0

I have this working in a bootstrap site via jQuery. Here's how I hid the 3rd and 4th (index 2 and 3) columns when the browser is narrow (under 768 px).

dataBound: function () {
    $("#contacts tr > td:nth-child(2)").addClass("hidden-xs");
    $("#contacts tr > td:nth-child(3)").addClass("hidden-xs");
    $("#contacts thead th:nth-child(2)").addClass("hidden-xs");
    $("#contacts thead th:nth-child(3)").addClass("hidden-xs");
    $("#contacts colgroup col:nth-child(2)").addClass("hidden-xs");
    $("#contacts colgroup col:nth-child(3)").addClass("hidden-xs");
}

Unfortunately this creates an index dependency, so you can't shuffle your columns around without updating these rules.

Christopher
  • 10,409
  • 13
  • 73
  • 97
  • You can also add these bootstrap classes in the corresponding column definitions, using the `attributes` and `headerAttributes` configuration parameters, but then you get a big blank space on the right, because the rest of the visible columns are not resized, as described in this Kendo UI forum post: http://www.telerik.com/forums/kendo-grid-responsive-behavior – AsGoodAsItGets Jan 11 '17 at 14:16
  • You can get rid of the giant white space by hiding the `colgroup` that occurs directly above the main `tbody` – bkwdesign Apr 19 '18 at 20:29
0

I have written a JQuery based widget with can be used to make a Kendo Ui Grid responsive.

You can get the widget here: https://github.com/loanburger/ResponsiveKendoGrid

Usage: After creating your grid add the following code:

$('#GridId').responsiveGrid(
{  columnsToShow: ['date','name','surname'],  columns you want to show in responsive view
   mobileWidth: 860, // screen width to trigger the change
   idColumn: 'Id', //ID column
   tools: ['excel'] // if you have the excel export option or blank if not
});

What it does is is basically only keeps the first column and hides the other columns but changing the client template used. It then created a items using the columns you specified and stacks then top down.

This works for me in most cases where I am just displaying data but not for inline editing or inline custom controls - that's coming later..

TResponse
  • 3,940
  • 7
  • 43
  • 63
-1

Yes., you can do it by setting width for Grid columns.

if you set columns width, kendo will automatically enable horizontal scrolling for smaller resolutions.

Muthu
  • 770
  • 5
  • 13