Grid Column.Bound(array[])

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

    Posted 04 Apr 2013 Link to this post

    Hello!!!
    I have a question!
    I use this example:http://www.kendoui.com/code-library/mvc/grid/binding-to-datatable.aspx
    Please show on this example how to edit object (row)

    and next:
    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:
    @(
     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()
    )
    Why Grid dosn't want work with array(
    How I can this do?
    for (int i = 0; i < Model.FirstOrDefault().Wetness.Count(); i++)
                        {
                        columns.Bound(o => o.Wetness[i]);
                               
                        }

  2. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2194 posts

    Posted 05 Apr 2013 Link to this post

    Hi Gusev,

     
    Basically the grid columns can be bound only to the object properties - in current case it seems that you are trying to bind the column to the values of given property which is invalid configuration. Please check the example below of rendering the given property values in current column using ClientTemplate:

    e.g.:

    columns.Bound(p => p.Wetness).ClientTemplate("#=generateTemplate(Wetness)#");

    function generateTemplate(Wetness) {
        var template = "<ul>";
        for (var i = 0; i < Wetness.length; i++) {
            template = template + "<li>" + Wetness[i] + "</li>";
        }
     
        return template + "</ul>";
    }
    Kind Regards,
    Vladimir Iliev
    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 05 Apr 2013 Link to this post

    I made as written, but nothing to changed

    columns.Bound(p => p.Wetness).ClientTemplate("#=generateTemplate(Wetness)#");
     
    <script type="text/javascript">
        function generateTemplate(Wetness) {
            var template = "<ul>";
            for (var i = 0; i < Wetness.length; i++) {
                template = template + "<li>" + Wetness[i] + "</li>";
            }
            return template + "</ul>";
        }
    </script>
  4. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2194 posts

    Posted 08 Apr 2013 Link to this post

    Hi Gusev,

    Could you please provide runable project where the issue is reproduced? This would help us pinpoint the exact reason for this behavior.

    Kind Regards,
    Vladimir Iliev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  5. Gusev
    Gusev avatar
    83 posts
    Member since:
    Dec 2012

    Posted 08 Apr 2013 Link to this post

    Hello!
    I corrected the error! ( .Server was instead.Ajax )
    And now I want know, how I can edit any object?
    I need EditorTemplates? (Need I use Mode.PopUp with template?) 
    And If I click UpdateButton in CustomPopUp Window, will come my Wetness to Controller (method Edit)? or only Thickness will come to Controller and Wetness will be equal to null
  6. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2194 posts

    Posted 09 Apr 2013 Link to this post

    Hi Gusev,

     
    I would suggest to check the "Using Multiselect in Grid" demo in the CodeLibrary which demonstrates how to use the MultiSelect widget as EditorTemplate in a InLine editable Grid. 
    The Grid is bound to the Employees collection of the Northwind database and the ComboBox allows you to edit the Territories navigation property generated by the Entity Framework ORM.

    Kind Regards,
    Vladimir Iliev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  7. Gusev
    Gusev avatar
    83 posts
    Member since:
    Dec 2012

    Posted 10 Apr 2013 Link to this post

    this is very good idea!!!
    thanks!

    but I have a small problem )
    I have this: first.png
    And editMode: second.png

    I want :

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

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

    sorry for bad my english
  8. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2194 posts

    Posted 10 Apr 2013 Link to this post

    Hi Gusev,


    As this thread is out of the original topic of this support conversation may I kindly ask you to open a new support thread for it (please attach current grid code and the editor template)? In this way you can be sure that your query will reach the corresponding staff member in time and will be answered faster and accurately.


    Kind Regards,
    Vladimir Iliev
    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