Set column.values property after grid has been initalized

5 posts, 0 answers
  1. Tyler
    Tyler avatar
    32 posts
    Member since:
    Jun 2011

    Posted 31 Oct 2013 Link to this post

    Is it possible to set the column.values property after the grid has been initialized?

    I tried this with no luck:

            var rankList = [
                { value: 1, text: "Rank 1" },
                { value: 2, text: "Rank 2" },
                { value: 3, text: "Rank 3" },
                { value: 4, text: "Rank 4" },
                { value: 5, text: "Rank 5" }
            ];
     
    $kendoGrid.columns.filter(function (item) {
                return item.field === "Rank";
            }).forEach(function (item) {
                item.values = rankList;
            });
            //reset the grids columns
            $kendoGrid.setOptions({ columns: $kendoGrid.columns });
            $kendoGrid.refresh();

    The grid was initially created using the MVC wrapper
       
    .Columns(columns =>
    {
        columns.Bound(p => p.UserAccountKey);
        columns.Bound(p => p.FirstName);
        columns.Bound(p => p.LastName);
        columns.Bound(p => p.EmailAddress);
        columns.Bound(p => p.Rank);
        columns.Command(command =>
        {
            command.Edit();
            command.Destroy();
        });
    })
  2. nikobellic
    nikobellic avatar
    46 posts
    Member since:
    Feb 2013

    Posted 01 Nov 2013 Link to this post

    Hi Tyler,

    Would it be possible for you to do something like this?

    http://jsfiddle.net/C5Ls2/
  3. Kendo UI is VS 2017 Ready
  4. Tyler
    Tyler avatar
    32 posts
    Member since:
    Jun 2011

    Posted 01 Nov 2013 Link to this post

    The grid is initially being created by the MVC wrapper so, destroying it and recreating it on the client i don't think will be a good option.  Also shouldn't setting the "values" property create a dropdown in the column?
  5. nikobellic
    nikobellic avatar
    46 posts
    Member since:
    Feb 2013

    Posted 01 Nov 2013 Link to this post

    You are right that changing the column values property on the fly is a somewhat complicated thing to achieve.
    Maybe someone has a better idea on how to get it done :s
    After you have done that, though, the dropdown gets created if the grid is set to editable.

    http://jsfiddle.net/RAXyJ/

    Hope this helps.
  6. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 04 Nov 2013 Link to this post

    Hi Tyler,

    Changing the Kendo UI Grid columns using the setOptions() method is not currently supported. The only way to achieve this that I can think of is to re-create the grid as Niko, already suggested. If you think that this feature should be added, please check the feedback section of the site and post your suggestion there.

    Regards,
    Kiril Nikolov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top
Kendo UI is VS 2017 Ready