Problem when selecting the option label dropdownlist in edit grid

6 posts, 1 answers
  1. Felipe
    Felipe avatar
    4 posts
    Member since:
    Nov 2012

    Posted 16 Jan 2013 Link to this post

    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?
  2. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 18 Jan 2013 Link to this post

    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!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Felipe
    Felipe avatar
    4 posts
    Member since:
    Nov 2012

    Posted 21 Jan 2013 Link to this post

    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
  5. Answer
    Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 23 Jan 2013 Link to this post

    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!
  6. Felipe
    Felipe avatar
    4 posts
    Member since:
    Nov 2012

    Posted 23 Jan 2013 Link to this post

    Thanks for the help.
     Where can I find more information about these codes that can be placed in the string?
  7. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 24 Jan 2013 Link to this post

    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!
Back to Top
UI for ASP.NET MVC is VS 2017 Ready