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

Custom View and DropDownList with resources

3 Answers 265 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Joanna
Top achievements
Rank 1
Iron
Joanna asked on 16 Sep 2015, 01:51 PM

Hi! 

I want to use this example:
http://docs.telerik.com/kendo-ui/web/scheduler/how-to/custom-edit-and-event-templates
But in ma case I want 'Owner' to be selected in edit mode, ie. when I click some event I see (in edit mode) 'Owner' is not selected, although on main schedular it shows as e.g "Alex".

Could you tell me how can I do this?

3 Answers, 1 is accepted

Sort by
0
Patrick | Technical Support Engineer, Senior
Telerik team
answered on 17 Sep 2015, 07:30 PM
Hi Joanna,

Take a look at this demo illustrating the Kendo Scheduler with the 'Owner' selected in the dropDownList.  In the demo you selected, it is not necessary to create any custom editing.

resources: [
            {
                field: "ownerId",
                title: "Owner",
                dataSource: [
                    { text: "Alex", value: 1, color: "#f8a398" },
                    { text: "Bob", value: 2, color: "#51a0ed" },
                    { text: "Charlie", value: 3, color: "#56ca85" }
                ]
            }
        ]

field will be the same name as the field in schema.model.fields.

Hope this helps, and let me know if you are doing things differently than the demo you described.

Regards,
Pat
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Joanna
Top achievements
Rank 1
Iron
answered on 18 Sep 2015, 06:59 AM
I use custome edit, that's why I have to use custom editing for resources. Without that it doesn't work at all. In your example there's no custom edit. But doesn't matter. I handle with it doing something like this:
var index = 0;
ownerId.dataSource.data(e.sender.resources[0].dataSource.data());
$.each(e.sender.resources[0].dataSource.data(), function (key, val) {
    if (val.value == e.event.ownerId) { index = key; }
});
ownerId.select(index);

0
Vladimir Iliev
Telerik team
answered on 22 Sep 2015, 08:31 AM
Hello Joanna,

Actually manually selecting the value of the dropDonwList is not required as the MVVM binding used for binding the model with the editor template will do it automatically when set-up correctly. Please check the example below:

<select id="ownerId" data-bind="value:ownerId" data-role="dropdownlist"
data-value-field="value" data-text-field="text">
  <option value="1">Alex</option>
  <option value="2">Bob</option>
  <option value="3">Charlie</option>
</select>

As in your case you need to get the resources directly from the scheduler you can use the following approach:

<select id="ownerId" data-bind="value:ownerId" data-source="{transport: {read: readSchedulerResources}}" data-role="dropdownlist" data-value-field="value" data-text-field="text">

function readSchedulerResources(request) {
       var scheduler = $("#scheduler").getKendoScheduler();
       request.success(scheduler.resources[0].dataSource.data().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!
 
Tags
Scheduler
Asked by
Joanna
Top achievements
Rank 1
Iron
Answers by
Patrick | Technical Support Engineer, Senior
Telerik team
Joanna
Top achievements
Rank 1
Iron
Vladimir Iliev
Telerik team
Share this question
or