Problem after having set the dropdown value

3 posts, 0 answers
  1. Michele
    Michele avatar
    426 posts
    Member since:
    Jun 2009

    Posted 29 Aug 2013 Link to this post

    Hello,
    I've a kendo UI grid that has a column with editortemplate....
    He're the grid

    @(Html.Kendo()
        .Grid<DO.Admin.Utente>()
        .Name("grid")
        .Columns(columns =>
        {
            columns.Bound(x => x.IDDipendente).Visible(false);
            columns.Bound(x => x.IDUtente);
            columns.Bound(x => x.Nominativo);
            columns.Bound(x => x.Societa);
            columns.Bound(x => x.Filiale);
            columns.Bound(x => x.Ruolo);
            columns.Bound(x => x.Profilo);
            columns.Bound(x => x.Funzioni);
            columns.Bound(x => x.Stato).EditorTemplateName("StatoTemplate");//ClientTemplate("#=stati.statiName#");
            columns.Bound(x => x.AccessoEureka);
     
        })
        .Pageable()
        .Scrollable()
        .Editable(editable => editable.Mode(GridEditMode.InCell))
        .DataSource(dataSource => dataSource
            .Ajax()
            .Model(model =>
            {
                model.Id(x => x.IDDipendente);
                model.Field(x => x.IDUtente).Editable(false);
                model.Field(x => x.Nominativo).Editable(false);
                model.Field(x => x.Societa).Editable(false);
                model.Field(x => x.Filiale);
                model.Field(x => x.Ruolo);
                model.Field(x => x.Profilo);
                model.Field(x => x.Funzioni);
                model.Field(x => x.Stato);
                model.Field(x => x.AccessoEureka);
                     
            })
            .Read(read => read.Action("GetListaUtenti", "GestioneUtenti"))
        )
    )

    And here's the editor template
    @{
        Layout = null;
    }
     
    @(Html.Kendo().DropDownList()
              .Name("Stato")
              .HtmlAttributes(new { style = "width: 250px" })
              .DataTextField("Descr")
              .DataValueField("ID")
              .DataSource(source =>
              {
                  source.Read(read =>
                  {
                      read.Action("GetListaStati", "Common", new { Area = string.Empty });
                  }).ServerFiltering(false);
              })
        )

    Consider the List of Stato items
    as

    0 | Active
    1 | Disactive

    when I show the grid in read I've my columns that shows Active/Disactive based on a field called Stato that's string....
    After I change the dropdown I got 0/1 instead.... how do I fix this?

    Second question, in my model I also have a IdStato that's 0/1 and its used when updating the model.... should I put this as an Hidden column? how do I update that field as well?
    Thank in advance
    Paolo
  2. Alexander Popov
    Admin
    Alexander Popov avatar
    1441 posts

    Posted 30 Aug 2013 Link to this post

    Hi Paolo,

    There is a similar scenario demonstrated in our offline examples located here:
    • "Path_to_KendoUI\wrappers\aspnetmvc\Examples\Areas\razor\Views\web\grid\editing_custom.cshtml"
    • "Path_to_KendoUI\\wrappers\aspnetmvc\Examples\Areas\razor\Views\web\grid\EditorTemplates\ClientCategory.cshtml"
    Using the approach shown in the above example you will not need to include the IdStato column.
    In case the provided information does not help you resolve the case please attach a runnable project where the issue is reproduced. This would help us pinpoint the exact reason for this behavior.

    Regards,
    Alexander Popov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Michele
    Michele avatar
    426 posts
    Member since:
    Jun 2009

    Posted 30 Aug 2013 Link to this post

    Hello Alexander,
    I've fixed using ForeignKey fields!
    Thats' ok! Thanks
Back to Top