KendoComboBox仅绑定值,而不是预先填充的某些字段的文本

时间:2019-01-08 15:17:50

标签: jquery data-binding kendo-ui kendo-datasource kendo-combobox

我目前正在将kendo组合框与json设施集(DMIS)绑定。有一个COMBINED字段,其中包含要绑定的设施的ID和标题。但是,只有ID会显示在框的预填充中。从组合框中选择其他设施时,一切都会显示出来。只是初始填充仅显示该ID,而应同时显示ID和TITLE。知道为什么它只显示ID以及如何在预填充时正确绑定ID吗?

    //ask a question dialog popup
    $("#askdialog").kendoDialog({
        open: function () {
            $("#facility").kendoComboBox({
                dataTextField: "Combined",
                dataValueField: "DMISID",
                filter: "contains",
                autoBind: true,
                minLength: 2,
                dataSource: {
                    serverFiltering: true,
                    transport: {
                        read: function (options) {
                            console.log(options);
                            if (typeof options.data.filter != "undefined" && options.data.filter != null &&
                                typeof options.data.filter.filters != "undefined" && options.data.filter.filters != null && options.data.filter.filters.length > 0) {
                                var DMIS_NAME = options.data.filter.filters[0].value;
                                if (DMIS_NAME.length > 1) {
                                    $.ajax({
                                        dataType: "json",
                                        url: DMIS_URL + DMIS_NAME,
                                        success: function (data) {
                                            console.log(data);
                                            options.success(data);
                                        },
                                        error: function (xhr, status, err) {
                                            console.log(err + "Error Status:" + status);
                                            options.error();
                                        }
                                    });
                                } else {
                                    options.success([]);
                                }
                            } else {
                                options.success([]);
                            }
                        }
                    },
                }
            });
        },
        visible: false,
        width: "500px",
        title: "Ask a Question",
        content: "<div id='new-question-form'>" +
            //"<h5 class='h5'>Ask Your Own</h5>" +
            "<input name='Prefix' id='prefix' placeholder='Prefix' type='text' class='k-textbox' maxlength='50' data-bind='value: Creator.NamePrefix' />" +
            "<input name='First Name' id='firstname' placeholder='First Name (Required)' type='text' class='k-textbox' maxlength='300' data-bind='value: Creator.FirstName' required />" +
            "<input name='Last Name' id='lastname' placeholder='Last Name (Required)' type='text' class='k-textbox' maxlength='300' data-bind='value: Creator.LastName' required />" +
            "<select id=\"facility\" style=\"width:100%;\" id='facility' name='Facility' placeholder='Facility (Required)' required></select>" +
            "<input name='Email' id='email' placeholder='Email (Required)' type='text' class='k-textbox' maxlength='300' data-bind='value: Creator.Email' required />" +
            "<input name='Phone' id='phone' placeholder='Phone (Required)' type='text' class='k-textbox' maxlength='50' data-bind='value: Creator.Phone' required />" +
            "<input name='DSN' id='dsn' placeholder='DSN' type='text' class='k-textbox' maxlength='50' data-bind='value: Creator.PhoneDSN' />" +
            "<p class='directions separate'>If you have multiple questions, please submit them in separate inquiries.</p><p class='directions caution'><span style='font-weight: bold;'>Caution:</span> <span style='font-style: italic;'>Do not include Personally Identifiable Information (PII).</span></p>" +
            "<textarea name='Text' rows='6' id='textbox' placeholder='Enter Question Here' class='k-textbox' data-bind='value: Question' required></textarea>" +
            //"<div id='chdButton'><button id='chd-new-button' type='submit' class='btn btn-green'>Submit</button></div>" + data-bind='value: Creator.DMIS'
            "</div>",
        actions: [
            { text: 'Submit', action: submitForm, primary: true }],
        buttonLayout: "stretched"
    }).data("kendoDialog");


        function onGetCurrentUserSuccess(data, request) {
            newInquiry = kendo.observable({
            Creator: {
                NamePrefix: data.NamePrefix,
                FirstName: data.FirstName,
                LastName: data.LastName,
                DMIS: data.DMIS,
                Email: data.Email,
                Phone: data.Phone,
                PhoneDSN: data.PhoneDSN,                           
            },
            Status: {
                Name: "Pending"
            },
            Question: ""
        });

        //post new inquiry to grid / update pre-population fields
        kendo.bind($("#askdialog"), newInquiry);

0 个答案:

没有答案