Grid Dynamic Title from Grid model

2 posts, 0 answers
  1. bapuy
    bapuy avatar
    4 posts
    Member since:
    Feb 2015

    Posted 25 Feb 2015 Link to this post

    Hi There,

    I would like to do dynamic columns using list item from MyModel, can i change the column "title" base on MyModel?

    MyModel
    {
         List<Item> Items;
    }


    Please refer to code below : 

    @(Html.Kendo().Grid<MyModel>()
        .Name("gridStudentList")
        .Columns(columns =>
        {


            for (int i = 0; i < 3; i++)
            {

                columns.Bound(c => c.Items[i].Product).Title("Can i use Mymodel property here?").Filterable(false); 
                columns.Bound(c => c.Items[i].ProductPrice).Filterable(false); 
            }

        })
    Thanks for your time. Regards,






  2. Dimo
    Admin
    Dimo avatar
    8475 posts

    Posted 27 Feb 2015 Link to this post

    Hello Bapuy,

    The desired behavior is possible to achieve if you use auto-generated columns (i.e. no Columns() configuration at all). In this case the Grid will generate the column titles based on the data. You can define the column titles via data annotation attributes in the Model.

    [DisplayName("Product name")]
    public string ProductName
    {
        get;
        set;
    }



    Regards,
    Dimo
    Telerik

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top