Custom editor parameters not being written out

8 posts, 0 answers
  1. Paul
    Paul avatar
    24 posts
    Member since:
    Aug 2013

    Posted 06 Aug 2014 Link to this post

    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.
  2. Paul
    Paul avatar
    24 posts
    Member since:
    Aug 2013

    Posted 07 Aug 2014 in reply to Paul Link to this post

    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.
  3. Paul
    Paul avatar
    24 posts
    Member since:
    Aug 2013

    Posted 07 Aug 2014 in reply to Paul Link to this post

    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?
  4. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2596 posts

    Posted 11 Aug 2014 Link to this post

    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!
     
  5. Paul
    Paul avatar
    24 posts
    Member since:
    Aug 2013

    Posted 12 Aug 2014 in reply to Kiril Nikolov Link to this post

    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.
  6. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2596 posts

    Posted 14 Aug 2014 Link to this post

    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!
     
  7. Paul
    Paul avatar
    24 posts
    Member since:
    Aug 2013

    Posted 14 Aug 2014 in reply to Kiril Nikolov Link to this post

    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.
  8. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2596 posts

    Posted 18 Aug 2014 Link to this post

    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!
     
Back to Top