Changing Columns after grid initialization

1 Answer 4024 Views
Grid
Niloofar
Top achievements
Rank 1
Niloofar asked on 20 Mar 2016, 08:39 PM
I have a grid (integrated into ember/javascript) with an ajax response assigned as its datasource. Based on the response I can come up with my column title and width and i want to assign that to my grid. But everything i do i dont see any change reflected to the grid. I was wondering how i can change column properties after grid initialization.

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 21 Mar 2016, 11:32 AM
Hello Niloofar,

In order to change the titles for particular columns and apply those changes you could retrieve the options that were used for the initialization of the widget with getOptions method, change the column from the columns collection as per your requirement and then use the setOptions method to pass the new settings:
var grid = $("#grid").data("kendoGrid");
var options = grid.getOptions();
options.columns[0].title = "new title";
grid.setOptions(options);

Hope this helps.


Regards,
Konstantin Dikov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Niloofar
Top achievements
Rank 1
commented on 23 Mar 2016, 12:33 PM

Thanks it worked!
Dave
Top achievements
Rank 1
commented on 01 Nov 2018, 03:50 PM

I have a question about how to access the column when column reorderable is set to true for the grid.   In this example the column is accessed via the index i.e.. options.columns[0].title.  This only works when reorderable is set to false.  Thanks so much for any help. 
Konstantin Dikov
Telerik team
commented on 05 Nov 2018, 10:41 AM

Hi Dave,

The columns collection will contain the reordered columns, so if you want to access a specific column you could traverse the columns collection and check the "field" property to find it.

If you have something different in mind, please provide more information about the exact requirement.


Regards,
Konstantin Dikov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Niloofar
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or