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

Problem when selecting the option label dropdownlist in edit grid

5 Answers 228 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Felipe
Top achievements
Rank 1
Felipe asked on 16 Jan 2013, 01:32 PM
Hi,

I have a class called Appointment, and within other classes have a service call and time stopped, follows below:

public class Appointment
{
        / / ...
        / / other properties

         [UHint ("ServiceEditor")]
         public Service Service {get; set;}

        [UHint ("ServiceEditor")]
         public Service Service {get; set;}
}

public class Service
{
       
         public int Id {get; set;}

         public string Name {get; set;}
}

public class TimeStopped
{
       
         public int Id {get; set;}

         public string Description {get; set;}
}

/ / View Editor:
@ (Html.Kendo (). DropDownList ()
     . Name ("Service")
     . DataValueField ("Id")
     . DataTextField ("Name")
     . BindTo ((System.Collections.IEnumerable) ViewData ["services"])
       . OptionLabel ("Select"))

The rule is if a note has a service he can not have hours parade and vice versa. Suppose the User selected a service, ok the change happens, but when he comes back to kendo option select throws a TypeError exception: Service is null

already tried to fix this but so far have found nothing = / what should I do?

5 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 18 Jan 2013, 12:38 PM
Hello Felipe,

I am not sure if I understand the exact scenario. Is it possible to share the full code you are using or a runnable sample so I can check the setup?

Kind regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Felipe
Top achievements
Rank 1
answered on 21 Jan 2013, 11:44 AM
HI,

Follows a one app from example of my problem. The rules of app  are as follow:

In my grid i have an entity called Service and another called TimeStopped. The user of this app can only launch a service or an time stopped per record. Suppose the user launched a wrong registry,instead of selecting one timestopped, selected a wrong service. When the User attempts to return the service to the default optionlabel the grid throws exception "TypeError exception: Service is null".



sample App
0
Accepted
Daniel
Telerik team
answered on 23 Jan 2013, 08:27 AM
Hello Felipe,

Thank you for sending a sample project and for the additional information. The error is thrown because the Service.Name is accessed directly in the ClientTemplate. This way when the Service is null an error is thrown when accessing the Name. In order to avoid this, you can use a condition in the template. For convenience I attached the modified project.

Regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Felipe
Top achievements
Rank 1
answered on 23 Jan 2013, 11:48 AM
Thanks for the help.
 Where can I find more information about these codes that can be placed in the string?
0
Daniel
Telerik team
answered on 24 Jan 2013, 06:02 PM
Hello again Felipe,

Information about the Kendo Templates syntax is available in this documentation topic.

Regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
DropDownList
Asked by
Felipe
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Felipe
Top achievements
Rank 1
Share this question
or