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

RadGrid / EntityDataSource BestPractice

1 Answer 37 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jochen
Top achievements
Rank 1
Jochen asked on 09 Oct 2014, 11:03 AM
Hello,

I searched a while but didn't find an appropriate Example.

I have a RadGridView bound to a EntityDataSource (EF 6). Everthing works fine (Sorting, Filtering), but now I ran into some Gotchas:

I have a primary key column ( = Entity Property) that is not shown in the grid, but I want to set a default filter on that column. When I try to use the where-property (AutoGenerateWhereClause = true) of the EntityDataSource I run into conflicts with the standard grid column filters. Which is the best way to achieve that?

I neet to fill additional column values when inserting new items, especially the primary keys. How should i do this?

Greetings Jochen

1 Answer, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 13 Oct 2014, 01:19 PM
Hi,

Indeed when the grid performs filtering through the EntityDataSource it will also generate where clause for the user entered filter values. If you need to add additional manual filter values you can handle the ItemCommand event and check for e.CommandName == RadGrid.FilterCommandName then modify the filter expressions of the control as shown at the end of this help topic:
http://www.telerik.com/help/aspnet-ajax/grid-operate-with-filter-expression-manually.html
For the insert operation you can use the InsertCommand event of the grid as mentioned in the support ticket reply.
Another option of setting default values is also through the markup of the grid - in this case they will be applied for all rows in the control. For example:
<telerik:GridBoundColumn DefaultInsertValue="Some value" UniqueName="Name" DataField="Name" HeaderText="Name"/>

For filtering you can also use the code-behind approach on initial load shown here:
http://www.telerik.com/help/aspnet-ajax/grid-applying-default-filter-on-initial-load.html

I hope this helps.

Best Regards,
Marin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Jochen
Top achievements
Rank 1
Answers by
Marin
Telerik team
Share this question
or