How to get a Telerik Grid to display only records with todays date on?
I need a Telerik grid to only display records where the date recorded matches today's date.
Edit - Presently I have the db connected up to my projec开发者_JS百科t via an edmx but the only kind of filtering I've done before on the tables has been in viewmodels to work with drop downs, so I'm unsure what steps I need to take with a Telerik grid.
You can simply filter the datasource before binding.
EDIT:
Supposedly you are using the MVC extensions from Telerik then you might do something like:
<%= Html.Telerik().Grid(Model)
.Name("Grid")
.Filterable(filtering => filtering.Filters(filters =>
{
filters.Add(o => o.ContactName).StartsWith("Paul").And().EndsWith("Wilson");
}))
%>
As seen on the Telerik demos: http://demos.telerik.com/aspnet-mvc/grid/filtering
I've only used the Telerik library with WebForms and it's a bit different there.
Just need to add a Where clause to your query whether your using Entity Framework or T-SQL and check your datetime column against the current date .NET DateTime.Now() or in T-SQL GetDate()
Examples
myDB.myTable.Where(m => m.CreateDate == DateTime.Now())
or
Select col1, col2, colDate From table1 Where colDate = GetDate()
精彩评论