I need to repopulate the scheduler when a new user has been selected in a companion grid on the page. I get the selection event with no problem. Now I just need to know the best way to tell the scheduler to retrieve fresh data from the server based upon the value in the selection event. After reading through much of the documentation and many of these threads I have come to the conclusion I need to set the dataSource to "serverFiltering: true" and then simply set a new filter. That didn't call my "Get" function so I tried to force a read call directly. Still nothing. Am I approaching this correctly? What is the best way to handle this?
function onSelectProvider(arg) {
$("#scheduler").filter = { field: "Idd", operator: "eq", value: arg.Text };
$("#scheduler").dataSource.read();
}
5 Answers, 1 is accepted
If I understood your scenario correctly, you need to sent an additional parameter to the server when scheduler is databound in order to filter the data. This can be achieved via the DataSource's transport read settings.You will need to rebind the Scheduler DataSource and pass the appropriate field from the currently selected record in the Grid widget. How to configure this is demonstrated in this test page. Please note that in the sample, data will not be filtered as the remote service does not support this operation, however, the data send with the request will be correct.
Regards,Rosen
Telerik

1. Can you show me how to do that with MVC?
2. Because of your answer I am now confused about the role the schema and parameterMap play. I thought the way to pass back data was to define your model in the parameterMap and then fill it somehow. What is the difference between the three then? (data, schema, parameterMap)

in the .cshtml file:
var selectedProviderId = -1;
function onSelectProvider(arg) {
selectedProviderId = arg.ProviderId;// $("#providers-grid").select().data("id");
$("#scheduler").dataSource.read();
}
dataSource: {
autoSync: true,
serverFiltering: true,
transport: {
read: {
url: "@Url.Action("Read", "Scheduler")",
dataType: "json",
data: { providerId: selectedProviderId }
},
create: {
type: "POST",
url: "@Url.Action("Create", "Scheduler")",
dataType: "json",
data: { providerId: selectedProviderId }
},
...
}
in the controller
public virtual JsonResult Read([DataSourceRequest] DataSourceRequest request) // , int providerId)
{
var sessions = SessionRepository.Instance.GetAllByProviderId(??); where is the value coming from?
...
return Json(appointments.ToDataSourceResult(request));
}
public virtual JsonResult Create([DataSourceRequest] DataSourceRequest request, TaskViewModel task) // , int providerId)
{
if (ModelState.IsValid)
{
//sessionService.Insert(task, ModelState);
}
return Json(new[] { task }.ToDataSourceResult(request, ModelState));
}
- You can find attached the same as previous sample but in a ASP.NET MVC application.
In case you are using the Scheduler for ASP.NET MVC you should use the DataSource Read Data option to pass the additional parameters:
@(Html.Kendo().Scheduler<KendoUIMvcApplication2.Models.TaskViewModel>()
.Name(
"scheduler"
)
//..
.DataSource(d => d
.Read(read => read.Action(
"Read"
,
"Home"
).Data(
"additionalData"
))
//..
)
)
<script>
function additionalData(e) {
//get the value of the selected record in the grid
var grid = $(
"#grid"
).getKendoGrid();
var row = grid.select();
if
(row.length) {
return
{
user: grid.dataItem(row).
get
(
"value"
)
}
}
}
</script>
public
virtual
JsonResult Read([DataSourceRequest] DataSourceRequest request,
int
? user)
{
var data = taskService.GetAll();
if
(user.HasValue)
{
data = data.Where(t => t.OwnerID == user);
}
return
Json(data.ToDataSourceResult(request));
}
- As stated in the documentation:
- The transport.[operation].data is place to assign additional parameters which to be sent to the remote service. It is similar to jQuery.ajax's data option.
- The parameterMap is a function which converts the request parameters (both the DataSource sort, filter, etc. operation descriptors and model changes, as well as custom ones assign via the transport data) to a format suitable for the remote service.
- The schema describes the remote service response
- The additional parameter should be mapped (if configured correctly) to a parameter with the same name in the appropriate action.
Regards,Rosen
Telerik
