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

Custom editor parameters not being written out

7 Answers 86 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 06 Aug 2014, 03:59 PM
Hi guys,

So I have a custom editor template which looks like this:

<script id="editor" type="text/x-kendo-template">
    <div >
        <h3>Create appointment</h3>
        <p>
        <label>Notes: <textarea name="notes"></textarea></label>
        </p>
        <p>
        <label>Employee:
            <select ng-controller="Employees" name="employee_uid" class="form-control" required>
                <option ng-selected="{{e.uid == @Model.m_sesson.m_staffGuid}}" value="{{e.uid}}" ng-repeat="e in employees"   >{{e.first_name}} {{e.last_name}}</option>
            </select>
        </label>
        <p>
        <label>Client:
            <select ng-controller="Clients" name="client_uid" class="form-control" required>
                <option value="{{c.uid}}" ng-repeat="c in clients" >{{c.first_name}} {{c.last_name}}</option>
            </select>
        </label>
        </p>
        <p>
        <label>Start: <input data-role="datetimepicker" name="start" /></label>
        </p>
        <p>
        <label>End: <input data-role="datetimepicker" name="end" /></label>
        </p>
    </div>
</script>

And my schema looks like this:

schema: {
                model: {
                    id: "taskId", // The "id" of the event is the "taskId" field
                    fields: {
                        // Describe the scheduler event fields and map them to the fields returned by the remote service
                        taskId: {
                            from: "uid", // The 'TaskID' server-side field is mapped to the 'taskId' client-side field
                            type: "number"
                        },
 
                        client_uid: { type: "number" },
                        employee_uid: { type: "number" },
                        notes: { type: "text"},
 
                        start: { type: "date" },
                        end: { type: "date" },
 
                        title: { from: "notes", defaultValue: "No title", validation: { required: true } },
                        description: { from: "Description", defaultValue: "No description" },
                        recurrenceId: { from: "RecurrenceID", defaultValue: null },
                        recurrenceRule: { from: "RecurrenceRule", defaultValue: null },
                        recurrenceException: { from: "RecurrenceException", defaultValue: null },
                        isAllDay: { type: "boolean", from: "IsAllDay", defaultValue: false }
                    }
                }
            }

But the only fields which get written out (from my template) when I click 'save' on a new appointment are 'start' and 'end'.

Any idea why?

Cheers, Paul.

7 Answers, 1 is accepted

Sort by
0
Paul
Top achievements
Rank 1
answered on 07 Aug 2014, 10:13 AM
Ok, figured this out. The reason my <select> fields are not getting written out is that kendo detects they haven't changed. The problem is, it isn't writing out the starting value (selected item) of the <select> which I need it to.

Any ideas?

Cheers, Paul.
0
Paul
Top achievements
Rank 1
answered on 07 Aug 2014, 10:40 AM
Is this some kind of conflict between kendo and angular.js?

I notice that if I remove the ng-controller from my <select> it becomes impossible to have a default option, leading me to believe this might be by design?
0
Kiril Nikolov
Telerik team
answered on 11 Aug 2014, 07:46 AM
Hi Paul,

First of all apologies for the delayed response.

I have tried to reproduce the problem in a simple editor template example, but to no avail. Could you please check it out and let me know what I need to do in order to make it reproduce the issue?

http://dojo.telerik.com/aCiG

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Paul
Top achievements
Rank 1
answered on 12 Aug 2014, 11:03 AM
Hi Kiril,

I can't get your example to show a select element with a default option. I have changed the example to show what I mean - option 'one' should be auto selected, but isn't.

If it were auto-selected, it would not get written out when you press 'save'.

http://dojo.telerik.com/aCiG/4

Cheers, Paul.
0
Kiril Nikolov
Telerik team
answered on 14 Aug 2014, 06:52 AM
Hello Paul,

The problem is caused by the name attribute of the select option. As the attribute points to invalid value in the dataSource the MVVM binding will not work correctly and the selected option is not applied. Please check the updated example:

http://dojo.telerik.com/aCiG/5

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Paul
Top achievements
Rank 1
answered on 14 Aug 2014, 09:03 AM
Hi Kiril,

Thanks for the reply. I've created a new example with an inline datasource which has the value contained in the name field and I still am not seeing a default select option:

http://dojo.telerik.com/aCiG/8

Appreciate any help you can give :)

Cheers, Paul.
0
Kiril Nikolov
Telerik team
answered on 18 Aug 2014, 07:38 AM
Hi Paul,

I have played a bit with the scheduler, and it turns out that the selected attribute is not being applied in the template, because after the template is initialized a value binding is performed, so a value from the dropdown is selected. In order to preselect you need to set a default value in the schema configuration, so the default option value is selected. Please check the following example and let me know if it helps:

http://jsbin.com/danus/1/edit

Regards,
Kiril Nikolov
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
Paul
Top achievements
Rank 1
Answers by
Paul
Top achievements
Rank 1
Kiril Nikolov
Telerik team
Share this question
or