Just editing your Scheduler example and if I create a custom template for the popup form to create a new event I have no access to the resources like you have in the stock popupform. How do I create that dropdown with the list of users from the resources in my custom template? Thanks.
6 Answers, 1 is accepted
0
Hello Ben,
In general, in the editor form template you will have access to the SchedulerEvent instance. If you would like to retrieve data from the Scheduler's data source, then you will need to get a reference to the object and then bind the widget. Here is a demo that demonstrates this in action. The demos wires the edit event of the widget and then binds the widget to the corresponding resource. Note that you can define the data statically in the custom editor template too, if it is not loaded dynamically.
Regards,
Georgi Krustev
Telerik
In general, in the editor form template you will have access to the SchedulerEvent instance. If you would like to retrieve data from the Scheduler's data source, then you will need to get a reference to the object and then bind the widget. Here is a demo that demonstrates this in action. The demos wires the edit event of the widget and then binds the widget to the corresponding resource. Note that you can define the data statically in the custom editor template too, if it is not loaded dynamically.
Regards,
Georgi Krustev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Ben
Top achievements
Rank 1
answered on 10 Nov 2014, 08:02 PM
awesome thanks. Have you got the markup from the demo template where you have a small coloured square next to each name in the dropdown?
0
Ben
Top achievements
Rank 1
answered on 10 Nov 2014, 08:10 PM
When I try your code I get Uncaught TypeError: Cannot read property 'dataSource' of undefined
my edit:
edit: function(e) {
var vehicleId = e.container.find("#vehicleId").data("kendoDropDownList");
console.log(vehicleId);
//bind the widget to the resources
vehicleId.dataSource.data(e.sender.resources[0].dataSource.data());
}
my template:
<div data-container-for="vehicleId" class="k-edit-field">
<select id="vehicleId" data-bind="value:vehicleId" data-role="dropdownlist"
data-value-field="value" data-text-field="text">
</select>
</div>
my edit:
edit: function(e) {
var vehicleId = e.container.find("#vehicleId").data("kendoDropDownList");
console.log(vehicleId);
//bind the widget to the resources
vehicleId.dataSource.data(e.sender.resources[0].dataSource.data());
}
my template:
<div data-container-for="vehicleId" class="k-edit-field">
<select id="vehicleId" data-bind="value:vehicleId" data-role="dropdownlist"
data-value-field="value" data-text-field="text">
</select>
</div>
0
Ben
Top achievements
Rank 1
answered on 10 Nov 2014, 08:16 PM
Never mind my bad I forgot to uncomment
editable: {
template: $("#editor").html()
},
so it was still using default...
editable: {
template: $("#editor").html()
},
so it was still using default...
0
bberdel
Top achievements
Rank 1
answered on 03 Jun 2016, 08:00 PM
I'm trying to do something similar, except my resource entry is using remote access rather than static values. When I assign the drop-down's data source in the edit event (as described in this post) I get [ object Object] for each line in the drop-down. What do I have to do to get the datasource to bind correctly?
Note: Please do not ask me to provide an application demonstrating the problem - that's just not feasible.
0
Hello Brian,
You can try different approach for loading the editor data - for example you can use custom dataSource "transport.read" operation as demonstrated below:
1) Inside the editor template:
2) On the page where the Scheduler is initialized:
Regards,
Vladimir Iliev
Telerik
You can try different approach for loading the editor data - for example you can use custom dataSource "transport.read" operation as demonstrated below:
1) Inside the editor template:
<
input
id
=
"someField"
name
=
"someField"
data-bind
=
"someField"
data-role
=
"dropdownlist"
data-value-field
=
"value"
data-text-field
=
"text"
style
=
"width:100%;"
data-source
=
"{transport:{read:getSomeFieldResourceData}}"
></
input
>
2) On the page where the Scheduler is initialized:
function
getSomeFieldResourceData(e) {
//make sure the id match your scheduler id
var
scheduler = $(
"#scheduler"
).data(
'kendoScheduler'
);
var
someFieldResourceIndex = 1;
//better solution is to find the index
var
resourcesData = scheduler.resources[someFieldResourceIndex].dataSource.view();
e.success(resourcesData.toJSON());
}
Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!