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

[Solved] Grid Ajax Binding - Very Confused

6 Answers 55 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Paul
Top achievements
Rank 1
Paul asked on 13 Jun 2011, 03:48 PM
OK,

So I followed the example in the help files under Grid->DataBinding->AjaxBinding thus: -

So now I am binding my grid to my IEnumerable of Orders ( a sub-filed in the ViewModel). All well and good. Except for 1 problem...

The grid is showing a wrong column "Entity State" which I can't get rid of using .Visible(false) nor using .Hidden(True). If I use Visible() or Hidden, then I simply lose the entire grid !

How can we fix that. I have even tried a data annotation set-up for that column which doesn't work...

Please Help...

6 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 13 Jun 2011, 04:00 PM
Hi Paul,

 Entity State may appear if you are using auto generated columns and entity framework. Is this the case? The grid creates a column for every public property of your model which includes EntityState for EF models. The solution is to  define the columns which the grid must display:

<%= Html.Telerik().Grid()
                  .Columns(columns =>
                  {
                         columns.Bound(c => c.Name);
                         columns.Bound(c => c.ID);

                  }) 
%>

Regards,
Atanas Korchev
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Paul
Top achievements
Rank 1
answered on 13 Jun 2011, 04:02 PM
Isn't that what DataAnnotations are for though ?...

i.e. ScaffoldColumn - or does the grid ignore this and its only applicable to Forms.
Is there any way to decorate the Entity with Metadata to include/exclude columns for telerik grids ?

Paul.
0
Atanas Korchev
Telerik team
answered on 13 Jun 2011, 04:04 PM
Hi Paul,

 If you decorate a property with [ScaffoldColumn(false)] it will not be displayed by the grid.

Regards,
Atanas Korchev
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Paul
Top achievements
Rank 1
answered on 14 Jun 2011, 06:39 AM
Now I understand...

Once you "take control" of the columns by using the ".Columns()" construct, you are in effect telling the grid to stop auto-generating and use what you tell it to use in the statements that follow.

I [rather stupidly] thought that you were setting attributes of the columns that the grid had already decided to render.

It isn't all that clear that this is what happens though - I'm quite sure I'm not the first to get caught like this or that I will be the last !...

BUT - Thanks for all your help & support - its greatly appreciated especially since the MVC stuff is "just so cheap" ;-)

Actually; it would be good to still allow auto-generation with Data Annotations and the like, but provide a further mechanism to "hide" the auto-generated columns from the grid without taking full control over the columns and completely losing the auto-generate feature. Next release perhaps ?... :-)

Paul.
0
Atanas Korchev
Telerik team
answered on 14 Jun 2011, 07:04 AM
Hi Paul,

 This is actually possible already. Go check the autogenerated columns example. The description shows how to hide an autogenerated column.

Kind regards,
Atanas Korchev
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Paul
Top achievements
Rank 1
answered on 14 Jun 2011, 08:16 AM
Hey, cool, I really should jump on the web-site and look at the examples more often.
I just sit here behind my companies slooooow internet connection with my help files.
Tags
Grid
Asked by
Paul
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Paul
Top achievements
Rank 1
Share this question
or