Alexander
Alexander

Reputation: 203

Add extra columns after initial load (Telerik MVC Grid)

I want to be able to add extra columns after the grid has been loaded. The user should be able to submit a form from the top of the page where the user may checks a checkbox, and then the page updates with the newly added column to the grid.

As an example, if I have two columns from the initial load and the user wants to add a third column. How can I achieve this technically? I saw an example of creating a new GridColumnSettings, though I don't think that's what I want.

Upvotes: 0

Views: 746

Answers (1)

Brandon
Brandon

Reputation: 993

The Telerik documentation about column settings is pretty good:

http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-grid-columns.html#ColumnConfig

I feel like you have two options.

One is to use the Hidden method when generating the columns, and then use javascript to "un-hide" the extra columns when they click a button.

The other option is to selectively render the columns or not on the sever side. Take the value of the checkbox, and pass that to the Visible method of the column in your column definintion code.

Upvotes: 1

Related Questions