Problem with kendo dropdownlist

8 posts, 0 answers
  1. Goldfy
    Goldfy avatar
    6 posts
    Member since:
    Oct 2013

    Posted 07 Nov 2013 Link to this post

    Hi: I have the following problem with my Kendo dropdownlist:
       In the model I pass to my view I have a list of Users, that I want to link to a dropdownlist called UsuariosDrpDwn
     and show it in a certain column("Usuario") of every row of my grid ( marked bold).
        
       I program the dropdownlist and it populates allright with the users, but when I link it to one of my grid's columns("Usuario"), the problem is it's values spread along the rows of the grid. Let's say my users are John, Martha, Grant, Michael. What happens is, John appears in the column "Usuario" of the first row, Martha in the column Usuario of the second row, Grant in the column Usuario of the third row, and Michael in the fourth.
          
       These is the code for the dropdownlist:

    @(Html.Kendo().DropDownListFor(d=>d)
                .Name("UsuariosDrpDwn").HtmlAttributes(new { @style = "font-size:12px" })
                .DataTextField("NombreUsuario")
                .DataValueField("IdUsuario")
                .BindTo(Model)
                )
    And this the code for my grid, I mark bold the column that is bounded to the dropdownlist:
            @(Html.Kendo().Grid(Model)
            .Name("Grid")
             .Columns(columns=>
              {
                columns.Bound(d => d.BorradoLogico).Title("Borrado logico");
                columns.Bound(d => d.FTick).Title("Ftick");
                columns.Bound(d => d.NombreUsuario).Title("Usuario").EditorTemplateName("UsersDrpDwn");
               @columns.Command(command => { command.Edit(); command.Destroy(); }).Width(172);
              })
       I attach my view.
  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 07 Nov 2013 Link to this post

    Hello,

     Could you please clarify what "the problem is it's values spread along the rows of the grid" means? A screenshot would help a lot.

    Regards,
    Atanas Korchev
    Telerik
    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. Goldfy
    Goldfy avatar
    6 posts
    Member since:
    Oct 2013

    Posted 07 Nov 2013 Link to this post

    As I show in the attached Image: the dropdownlist is the one appearing on the right top part of the image, with the name Usuarios( marked with a red circle) .
    It's values are Alfonso(appears twice) and Juan (appears twice).

      The column of the grid where the values of the dropdownlist spread along is  called Usuario( marked with a red circle). As you can see in the photo, the users spread along the grid's rows. Alfonso in the first row of the grid, Alfonso again in the second row, then Juan in the third row of the grid, and again Juan in the fourth row . What I want is the dropdown to show in every cell Usuario of every row in the grid, being able to see all the users in it.
  5. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 07 Nov 2013 Link to this post

    Hello,

    The editor template will appear only when the current grid row is in edit mode. What happens when you click the edit button? Does the dropdown appear?

    The only problem I see is that you are setting the name of the dropdownlist in the editor template. When you use DropDownListFor the name is set automatically. Here is how the updated code should look like:

    @(Html.Kendo().DropDownListFor(d=>d)
                .DataTextField("NombreUsuario")
                .DataValueField("IdUsuario")
                .BindTo(Model)
                )

    In addition you can check the following online demos: 
    http://demos.kendoui.com/web/grid/editing-custom.html
    http://demos.kendoui.com/web/grid/foreignkeycolumn.html

    The help article about using editor templates could also be of help for you: http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/editor-templates

    If you need further assistance please attach a runnable version of your project to this forum thread. We will troubleshoot it for you and see what went wrong.

    Regards,
    Atanas Korchev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. Goldfy
    Goldfy avatar
    6 posts
    Member since:
    Oct 2013

    Posted 08 Nov 2013 Link to this post

    Atanas your solution doesn't work as I show in the image. When you say runnable version , is it enough with a compressed version of my Project folder + the ddbb script?
  7. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 08 Nov 2013 Link to this post

    Hi,

     A runnable version means a project which we can run at our side without any modifications or restoring database backups. 

    Regards,
    Atanas Korchev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  8. Goldfy
    Goldfy avatar
    6 posts
    Member since:
    Oct 2013

    Posted 08 Nov 2013 Link to this post

    is it enough with a compressed version of my Project folder + the ddbb script?
  9. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 08 Nov 2013 Link to this post

    Hello,

     It would be enough if we can run your project without any modifications and reproduce the problem you are having. Of course we can't tell that before we have the files.

    Regards,
    Atanas Korchev
    Telerik
    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