I have a view that contains a DatePicker and Grid.
I would load data to Grid, using DatePicker value.
I'm using a submit form that fires an Action.
I use this approach, because the data to be recovered are many and also have fields that must be calculated according to the date indicated, before loading the collection
What is the best practice to post the data filter and then load the data in the grid? I do not know how to do! :-(
01.
<
form
asp-action
=
"Item_Read"
asp-controller
=
"Home"
>
02.
<
p
>Filtri disponibili</
p
>
03.
<
div
class
=
"form-group"
>
04.
<
label
>Data</
label
>
05.
@(Html.Kendo().DatePicker()
06.
.Name("dateFilterDatepicker") // The name of the DatePicker is mandatory. It specifies the "id" attribute of the widget.
07.
.Min(new DateTime(1900, 1, 1)) // Sets the min date of the DatePicker.
08.
.Max(new DateTime(2099, 12, 31)) // Sets the max date of the DatePicker.
09.
.Value(DateTime.Today) // Sets the value of the DatePicker.
10.
.DateInput(true)
11.
)
12.
</
div
>
13.
<
div
class
=
"form-group"
>
14.
@(Html.Kendo().Button()
15.
.Name("textSearchButton")
16.
.HtmlAttributes( new {type = "submit"} )
17.
.Content("Ricerca")
18.
)
19.
</
div
>
20.
21.
<
div
class
=
"text-center form-group"
>
22.
@(Html.Kendo().Grid<
ItemModel
>()
23.
.Name("itemGrid")
24.
.ToolBar(t => t.Search())
25.
.Filterable()
26.
.Columns(columns =>
27.
{
28.
columns.Bound(f => f.No);
29.
columns.Bound(f => f.Description);
30.
columns.Bound(f => f.Brand);
31.
columns.Bound(f => f.NetChange);
32.
columns.Bound(f => f.PurchasesQty);
33.
columns.Bound(f => f.LastEntryDate).Format("{0:dd/MM/yyyy}"); ;
34.
35.
})
36.
.Pageable() // Enable paging
37.
.Sortable() // Enable sorting
38.
.Scrollable(scrollable => scrollable.Virtual(true))
39.
.HtmlAttributes(new { style = "height:430px;" })
40.
.DataSource(dataSource => dataSource //Configure the Grid data source.
41.
.Ajax() //Specify that Ajax binding is used.
42.
.PageSize(20)
43.
44.
)
45.
)
46.
</
div
>
47.
</
form
>