This is a migrated thread and some comments may be shown as answers.

Set column.values property after grid has been initalized

4 Answers 481 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tyler
Top achievements
Rank 1
Tyler asked on 01 Nov 2013, 12:07 AM
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();
    });
})

4 Answers, 1 is accepted

Sort by
0
Ignacio
Top achievements
Rank 1
answered on 01 Nov 2013, 07:50 PM
Hi Tyler,

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

http://jsfiddle.net/C5Ls2/
0
Tyler
Top achievements
Rank 1
answered on 01 Nov 2013, 07:55 PM
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?
0
Ignacio
Top achievements
Rank 1
answered on 01 Nov 2013, 08:11 PM
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.
0
Kiril Nikolov
Telerik team
answered on 04 Nov 2013, 09:30 AM
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!
Tags
Grid
Asked by
Tyler
Top achievements
Rank 1
Answers by
Ignacio
Top achievements
Rank 1
Tyler
Top achievements
Rank 1
Kiril Nikolov
Telerik team
Share this question
or