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

Data Source missing the Data property

2 Answers 158 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
AP
Top achievements
Rank 1
Iron
Iron
Veteran
AP asked on 30 Jul 2013, 02:23 PM
The scheduler implementation of the datasource differs from the usage in most of the other Kendo UI widgets.  It doesn't seem to have a data property, which can be used to pass parameters to the controller , to enable custom filtering to be done on the server.

I would like to display two sets of data on one scheduler, and control what is displayed from a drop-down list. This is easy to accomplish with a grid e.g.:-
.DataSource(dataSource=>dataSource
        .Ajax()
        .PageSize(20)
        .Model(m=>
            {
                m.Id(p => p.LogID);
            })
             
         
        .Read(read=>read.Action("GetCRISList","NonDALoads")
        .Data("srchLoad")
        )
        )
        .Pageable(p=>p.Refresh(true))
         .Sortable()
        .Filterable()
 
 
 
  <script type="text/javascript">
 
        var srch = 28;
 
        function selectionChange() {
 
            var dropdownlist = $("#loadDDL").data("kendoDropDownList");
 
            var dataItem = dropdownlist.dataItem();
 
            srch = dataItem.LoadID;
 
            //refresh Grid
            //$("#Grid").data("kendoGrid").dataSource.read();
 
            $('#Grid').data().kendoGrid.dataSource.page(1);
 
        }
 
    function srchLoad() {
        return {
 
 
            ID: srch
        };
    }
 
        </script>

However, I don't seem able to do this with the scheduler.  All I can see is a filter property, but since the data is coming from two different tables, handling the it this way is undesirable.

Currently I have two scheduler widgets in a tab control, but this causes some display issues, and is a bit clunky.

Thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
Vladimir Iliev
Telerik team
answered on 01 Aug 2013, 07:35 AM
Hi Andrew,

 
Please note that the Scheduler supports such Data function which to return additional parameters to the server for custom filtering - please check the example below:

1) Set the data function:

.Read(read => read.Action("Read", "Scheduler").Data("getFilterParameters"))

2) Create function which will return object that contains current Scheduler View start and end date:
function getFilterParameters() {
    var startDate = new Date(2013, 5, 4);
    var endDate = new Date(2013, 5, 13);
    return { start: kendo.format("{0:G}", startDate), end: kendo.format("{0:G}", endDate) };
}

3) Update the controller to accept the new start and end parameters and filter the data:
public virtual JsonResult Read([DataSourceRequest] DataSourceRequest request, DateTime? start, DateTime? end)
{
 
    if (start != null && end != null)
    {
        var filteredResult = taskService.GetAll().Where<TaskViewModel>(a => a.Start >= start && a.End >= end).Select(a => a);
 
        return Json(filteredResult.ToDataSourceResult(request));
    }
 
    return Json(taskService.GetAll().ToDataSourceResult(request));
}
Kind Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
AP
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 02 Aug 2013, 07:47 AM
Thanks, I'm not sure why I couldn't get it to work before.
Tags
Scheduler
Asked by
AP
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Vladimir Iliev
Telerik team
AP
Top achievements
Rank 1
Iron
Iron
Veteran
Share this question
or