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

Filtering date as string

1 Answer 311 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Víctor
Top achievements
Rank 1
Víctor asked on 17 Apr 2019, 12:43 PM

Hi,

I'm evaluating the grid with the trial version to see if your solution fits into our web application.

I'm trying to adapt the grid in our web asp.net MVC and I've encountered a problem with the filters date.

We need to enter "> = 1.1.2018" or "1.1.2018#31/12/2018" and it reaches FileDescriptor request as a value. With this i build the query to launch the SQL server. 

 Now no Filters arrive to request  from ajax "Consulta_Viajes"

@(Html.Kendo().Grid<ViewModels.ViajesViewModel>()
   .Name("grid")
   .EnableCustomBinding(true)
   .Columns(columns =>
        {columns.Bound(c => c.itdavia).Hidden();
         columns.Bound(c => c.ctdavia).Title(LocalizationResources.Strings.viaje);
         columns.Bound(c => c.ctrnest).Title(LocalizationResources.Strings.codigo_estado);
         columns.Bound(c => c.dtrnest).Title(LocalizationResources.Strings.estado);
         columns.Bound(c => c.ftdavia).Title(LocalizationResources.Strings.fecha_viaje).Groupable(false).Format("{0:dd/MM/yyyy}").Width(150);
         columns.Bound(c => c.htdavia).Title(LocalizationResources.Strings.hora_viaje).Groupable(false).Format("{0:HH:mm}");
         columns.Bound(c => c.cdvn).Title(LocalizationResources.Strings.codigo_division);
          })
    .Scrollable()
    .Groupable()
    .Sortable()
    .Filterable(ftb => ftb.Mode(GridFilterMode.Row)
                    .Extra(false))
   .Pageable()
   .Resizable(resize => resize.Columns(true))
   .Reorderable(reorder => reorder.Columns(true))
   .DataSource(dataSource => dataSource
      .Ajax()
      .Read("Consulta_Viajes", "AsignacionMensajero", new { strTabla = "tdavia" })
      .ServerOperation(true)
                                                    )
   .Deferred(true)
   .AutoBind(false))

 

How can I do this?

Thanks in advance.

Regards.

 

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 19 Apr 2019, 09:41 AM
Hello Victor,

If the underlying field that you need to filter is of DateTime type, you will have to use custom filter for the column in order to change the default filter component, so that it could allow entering string values instead of valid Date objects:
Another option would be to change the property in the model to string, which will allow you to filter with string values.


Regards,
Konstantin Dikov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Víctor
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or