This is a migrated thread and some comments may be shown as answers.

Lock Autogenerated Column In Kendo Grid

3 Answers 149 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stuart
Top achievements
Rank 1
Stuart asked on 14 Sep 2015, 08:28 AM

I have a DataSet that I'm generating on the fly.

I'm doing this by collecting all of my data and then building a DataTable and then using the DataTable as a DataSource for my Kendo Grid.

The Grid is set up to use AutoGenerated columns, like this ...

@(Html.Kendo().Grid(Model.Data)
  .Name("grid")
  .Columns(c =>
  {
    c.AutoGenerate(true);
  }
  .Scrollable()
  .Resizable(a =>
  {
    a.Columns(true);
  })
)

I want to freeze the first column in this Grid (I will always know what this column is).

I haven't found a way of manipulating the Columns at all when using AutoGenerated columns and have had to resort to a number of jQuery/CSS 'fudges' to get the Grid looking and behaving the way that I want it to.

However, I'm at a loss as to how I might be able to freeze a column when the Grid uses AutoGenerated columns.

Is is actually possible?

If it is, would you care to give me a hint as to how I might go about it?

3 Answers, 1 is accepted

Sort by
0
Stuart
Top achievements
Rank 1
answered on 14 Sep 2015, 10:03 AM

OK.

 

More digging turned up this Code Library post so I have modelled my solution on that.

Now I'm getting some proper weirdness when I try locking the column. Have a look at this Jing video and you'll see my point.

In short what happens is, if the grid is rendered with no locked columns, all works as expected. With the first column locked, the heading for that column shows but all the rows (for that column) are blank and they are blank because they have all been shifted right one column.

0
Accepted
Pavlina
Telerik team
answered on 16 Sep 2015, 09:17 AM
Hello,

When Grid scrolling is enabled, the Grid renders two tables. If frozen columns are used, there are four tables. If the Grid is not configured properly, or if there are some conflicting CSS styles on the page, the layout might break. 

I tested the code library you pointed with first columns locked and only the frozen column appears in the grid. The other columns do not occur because they have no widths. After I applied widths to the missing columns the problem disappear. Could you please confirm that missing column widths is not the problem in your case as well.

Regards,
Pavlina
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Stuart
Top achievements
Rank 1
answered on 16 Sep 2015, 09:21 AM

Pavlina,

 Stunning.

 Thank you.

Tags
Grid
Asked by
Stuart
Top achievements
Rank 1
Answers by
Stuart
Top achievements
Rank 1
Pavlina
Telerik team
Share this question
or