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

Kendo Grid - Filter DateTime column only by datepart in Asp.net MVC

1 Answer 470 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Adrian
Top achievements
Rank 1
Adrian asked on 18 Jul 2013, 12:01 PM
I am trying to filter a  Kendo grid DateTime column but it is not returning any results because it takes into account the time part as well. Is there a way I can filter a column without it using the timepart. Is it possible to filter the column by dd/MM/yyyy instead of dd/MM/yyyy hh:mm:ss

  Below is my grid code

View
@(Html.Kendo().Grid<PaperworkViewRecord>()
                .Name("IncompleteStartersPaperworkGrid")
                 .Sortable()
                .Pageable(paging => paging.PageSizes(new int[]{10,25,50,100,200}).Numeric(true).Numeric(true).PreviousNext(true))
                .Filterable()
                .Groupable()
                 .ColumnMenu()
                .Columns(columns =>
                {
                    columns.Bound(o => o.FirstName).Title("First Name");
                    columns.Bound(o => o.LastName).Title("Surname");
                    columns.Bound(o => o.BirthDate).Format("{0:dd/MM/yyyy}").Title("Birth date");
                    columns.Bound(o => o.StartDate).Format("{0:dd/MM/yyyy}").Title("Start Date").Template(o =>DateExtensions.FormatDate(o.StartDate));
                    columns.Bound(o => o.FrameworkName).Title("Framework");
                    columns.Bound(o => o.FundingStreamName).Title("Funding Stream");
                    columns.Bound(o => o.Assessor).Title("Assessor");
                    columns.Bound(o => o.ProviderName).Title("Provider").Hidden(true);
                    columns.Bound(o => o.IsFunded).Title("Funded").Hidden(true);
                    columns.Bound(o => o.AgeAtSignUp).Title("Signup Age").Hidden(true);
                    
                })
                .EnableCustomBinding(true)
                  .DataSource(dataSource =>dataSource.Ajax()
                                                        .Read( read=>read.Action("GetIncompleteStartersModel_Read", "Compliance"))
                                                        .ServerOperation(true))
                                                        
                .Events(e=>e.DataBound("onIncompleteStartersPaperworkGridDataBound"))
                )

DataSourceResult method

 public DataSourceResult GetIncompleteSignupStarterPaperworkRecords(DataSourceRequest request)
        {
            var paperworkRecords = _paperworkRepository.FetchByType(PaperworkType.Starter.ToString())
                                                       .Where(x => !x.SignupComplete);
            var paperworkDtoRecords = paperworkRecords.ToDataSourceResult(request, m => m.MapToPaperworkViewRecord());
            return paperworkDtoRecords;
        }


1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 22 Jul 2013, 07:58 AM
Hello Adrian,

I am afraid this is not possible.

You need to either project your collection and change each DateTime field of your objects to contain only the Date part.

Or you need to implement custom binding.

Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Adrian
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or