Cannot pass Data to Read datasource Method

2 posts, 1 answers
  1. Dario
    Dario avatar
    40 posts
    Member since:
    Jun 2018

    Posted 15 Apr 2020 Link to this post

    I would pass DatePicker value to datasource of grid, using Data method in this way

    <div class="d-inline">
                    .Name("dateFilterDatepicker") // The name of the DatePicker is mandatory. It specifies the "id" attribute of the widget.
                    .Min(new DateTime(1900, 1, 1)) // Sets the min date of the DatePicker.
                    .Max(new DateTime(2099, 12, 31)) // Sets the max date of the DatePicker.
                    .Value(DateTime.Today) // Sets the value of the DatePicker.
                        .HtmlAttributes( new {type = "submit"} )
        <div class="text-center form-group">
                  .ToolBar(t => t.Search())
                  .Columns(columns =>
                      columns.Bound(f => f.No);
                      columns.Bound(f => f.Description);
                      columns.Bound(f => f.Brand);
                      columns.Bound(f => f.NetChange);
                      columns.Bound(f => f.PurchasesQty);
                      columns.Bound(f => f.LastEntryDate).Format("{0:dd/MM/yyyy}"); ;
                  .Pageable() // Enable paging
                  .Sortable() // Enable sorting
                  .Scrollable(scrollable => scrollable.Virtual(true))
                  .HtmlAttributes(new { style = "height:430px;" })
                  .DataSource(dataSource => dataSource //Configure the Grid data source.
                      .Ajax() //Specify that Ajax binding is used.
                      .Read(read => read.Action("Item_ReadData", "Home").Data("additionalData")) // Set the action method which will return the data in JSON format.
            function additionalData() {
                var value = $("#dateFilterDatepicker").data("kendoDatePicker").value();
                return { selectedDate: value }; // send the filter value as part of the Read request
            function onClick() {
                var grid = $("#itemGrid").data("kendoGrid");
      ; // rebind the Grid's DataSource

    But I'm sure that date is valued, but it seems that not fires additionalData function when it request read method of datasource

    My action

            public IActionResult Item_ReadData([DataSourceRequest] DataSourceRequest request, DateTime selectedDate)
                var itemsFound = new List<ItemModel>();
                System.Security.Claims.ClaimsPrincipal currentUser = this.User;
                var scope = currentUser.Claims.ToList().SingleOrDefault(c => c.Type == "Scope")?.Value;
                using (DbNavision ctx = new DbNavision())
                    if (selectedDate != new DateTime(1, 1, 1))
                        itemsFound = (from rec in ctx.UpSrlItem
                                      select new ItemModel(rec, selectedDate, scope)).ToList();
                    var dataResult = itemsFound.ToDataSourceResult(request);
                    return Json(dataResult);


    The second parameter of action is ever empty, but if I remove it from action definition, is the same.

    what's wrong?

  2. Answer
    Georgi avatar
    698 posts

    Posted 20 Apr 2020 Link to this post

    Hi Dario,

    I have examined your configuration and I did not notice anything that might cause an issue. The additionalData handler should be executed if there are no js errors. You could add a console log within the handler to confirm if the dataSource calls it. I would also ask you to check if the there are any errors in the console of your browser.

    Furthermore, could you please check the payload of the request and make sure that the parameter is included? If it is, please make sure that the date is formatted correctly as the server might be unable to parse the value to a date.

    You could test with a different format as follows:

            function additionalData() {
                var value = $("#dateFilterDatepicker").data("kendoDatePicker").value();
                return { selectedDate: kendo.toString( value, "MM/dd/yyyy") }; // send the filter value as part of the Read request

    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
Back to Top