Grid template for edit (array[])

3 posts, 1 answers
  1. Gusev
    Gusev avatar
    83 posts
    Member since:
    Dec 2012

    Posted 10 Apr 2013 Link to this post

    Hello!
    I want  editing as here  http://www.kendoui.com/code-library/mvc/grid/using-multiselect-in-grid.aspx and 

    I have Model:
    public class ShrinkCoeffModel
        {
            [Display(Name = "thickness")]
            public virtual int Thickness { get; set; }
               
            [Display(Name = "wett")]
            public virtual string[] Wetness { get; set; }
       
            [Display(Name = "coeff")]
            public virtual decimal[] Coeff { get; set; }
        }
    and Grid: (1.png)
    @(
     Html.Kendo().Grid(Model)
                    .Name("ShrinkCoeff")
                    .ToolBar(commands =>
                    {
                        commands.Create();
                    })
                    .Columns(columns =>
                    {
                        columns.Bound(o => o.Thickness);
                        for (int i = 0; i < Model.FirstOrDefault().Wetness.Count(); i++)
                        {
                        columns.Bound(o => o.Wetness[i]);
                               
                        }
                        columns.Command(command =>
                        {
                            command.Edit();
                            command.Destroy();
                        }).Width(210).Title("Действия");
                    })
                    .Editable(editable => editable.TemplateName("Item").Mode(GridEditMode.PopUp))
                    .DataSource(dataBinding => dataBinding
                        .Server()
                                                        .Model(model => model.Id(o => o.Thickness))
                                                            .Update("Edit", "ShrinkCoeff")
                                                            .Create("Create", "ShrinkCoeff")
                                                            .Destroy("Delete", "ShrinkCoeff"))
                    .Pageable()
                    .Sortable()
                    .Selectable()
    )
    And if I click Edit I see this: 2.png 

    But I want :

    first Wetness             first Coeff                                                     
    second Wetness      second Coeff  
    .....                                  ......

    how to display  also to and edit
    how I can this do?

    (I can pass my model to EditorTemplates and use:
    @foreach(Type item in Model)
    {
    ......) 
    There are other ways?)
  2. Answer
    Daniel
    Admin
    Daniel avatar
    2219 posts

    Posted 12 Apr 2013 Link to this post

    Hello Gusev,

    You should create an editor template and specify that it should be used for the property by using the UIHint attribute. Please check this documentation topic for more detailed information on this matter.

    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. Gusev
    Gusev avatar
    83 posts
    Member since:
    Dec 2012

    Posted 15 Apr 2013 Link to this post

    Thanks!
    Something I forgot about this method :(
    Great Work!
Back to Top