We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to Set AutoComplete Field Value in Custom Schedule Window

Hi there ,

I have trying to set auto complete field value via AppointmentWindowOpen javascript method.

The field is defined like this

<td>
                        Assessment Type:
                    </td>
                    <td>
                        @Html.EJ().Autocomplete("AssesmentTypeID", (Syncfusion.JavaScript.Models.AutocompleteProperties)ViewData["autoAssessmentType"])
                    </td>

and the javascript method is something like..

function onAppointmentWindowOpen(args) {
        args.cancel = true;
        var quickobj = $("#Schedule1AppointmentQuickWindow").data("ejDialog");
        quickobj.close();
        $("#StartTime").ejDateTimePicker({ value: args.startTime });
        $("#EndTime").ejDateTimePicker({ value: args.endTime });
        if (!ej.isNullOrUndefined(args.target)) {
            /*if ($(args.target.currentTarget).hasClass("e-alldaycells"))
                $("#allday").prop("checked", true);
            else
                args.model.currentView == "month" ? $("#allday").prop("checked", true) : $("#allday").prop("checked", false);
                $("#StartTime,#EndTime").ejDateTimePicker({ enabled: ($(args.target.currentTarget).hasClass("e-alldaycells") || $(args.target.currentTarget).hasClass("e-monthcells") || args.model.currentView == "month") ? false : true });
            */
        }
        if (!ej.isNullOrUndefined(args.appointment)) {
            $("#customId").val(args.appointment.Id);
            $("#subject").val(args.appointment.Subject);
            $("#customdescription").val(args.appointment.Description);
           
            $("#StartTime").ejDateTimePicker({ value: new Date(args.appointment.StartTime) });
            $("#EndTime").ejDateTimePicker({ value: new Date(args.appointment.EndTime) });


having trouble setting autocomplete field value (following line)

 $("#AssesmentTypeID").ejAutoComplete({ value: new Date(args.appointment.AssesmentTypeID) });

if you could assist me on this that would be appreciated

Regards
Prasanth



1 Reply

KK Karthigeyan Krishnamurthi Syncfusion Team March 10, 2016 09:27 AM UTC

Hi Prasanth,

Thank you for contacting Syncfusion support.

We have prepared a sample for your requirement “Adding auto complete field in custom window” and that can be downloaded from the following location,
http://www.syncfusion.com/downloads/support/forum/123357/ze/custom_window-968675821

In the above sample, we have added auto complete field named owner in custom window. While opening the appointment which is saved with the owner value, custom window will display the owner value in auto complete field. Kindly refer to the following code example used in the above sample.
<Code>

function onAppointmentWindowOpen(args) {

        ---------------

        ---------------

        if (!ej.isNullOrUndefined(args.appointment)) {

            $("#customId").val(args.appointment.Id);

            $("#subject").val(args.appointment.Subject);

            $("#customdescription").val(args.appointment.Description);

            var ownerObject = $("#Owner").data("ejAutocomplete"); // here creating th object for auto complete control

            var ownerValue = ej.DataManager(ownerObject.model.dataSource).executeLocal(new ej.Query().where("id", "equal", args.appointment.OwnerId))[0]["text"]; // here we are filtering the owner value based on the id

            $("#Owner").ejAutocomplete("clearText");

            $("#Owner").ejAutocomplete({ text: ownerValue, value: ownerValue }); // here we are binding the owner value to auto complete field

            ---------------

            ---------------

            }

            $("#customWindow").ejDialog("open");

        }

        else

            $("#customWindow").ejDialog("open");
    }
</Code>  

We have checked the provided code example and found that you are trying to convert the auto complete field value in to date object which may be the cause for the issue. We request you to give the value to auto complete field as shown below.

<Code>

$("#AssesmentTypeID").ejAutoComplete({ value:args.appointment.AssesmentTypeID });

</Code>

Kindly try with the above suggestion and if still issue persist at your end try to reproduce the error in the above sample and send it back to us or you can share sample, if possible. We can analyze the mentioned scenario and provide you the possible solution.


Regards, 
Karthigeyan


Loader.
Up arrow icon