Hi,
I am using Asp.Net MVC & igGrid with autoGenerateColumns(true) and I am making the GridModel in my Controller's ActionMethod.
Since I have set the autoGenerateColumns(true) I cannot set the headerText on individual columns because they are generated automatically.
The reason I am using autoGenerateColumns(true) is because my grid will show data from different tables dynamically hence the datasource of the grid will change at runtime and I have only 1 ViewPage for the entire grid which gets its gridModel from action method of my controller. My ViewPage(.cshtml) contains only these lines and does not contain anything else, All other settings are written in actionMethod of my Controller.
-------------------------------------------------
ViewPage(.cshtml) for Grid [All the settings are in actionMethod of Cotroller]
@model Infragistics.Web.Mvc.GridModel
@Html.Infragistics().Grid(Model)
I want to set the HeaderText of my igGrid Columns manually. Initially I wanted to use the DataAnnotations of my model to automatically set them as headerText of the grid columns, but i think thats not a feature of infragistics uptil now, someone told me.
Now I want to iterate through the columns and set the HeaderText manually while autoGenerateColumns is set to true. Can this be done? How do i set the columns headers without explicitly defining every column?
If it cant be done then please suggest me an alternative.
How to use C# DataAnnotations to set Headertext or how to iterate through all the columns and set the HeadeText property or any alternative when autogenerateColumns(true) is set..? If there is no other way than how can i generically specify the columns of grid without writing redundant code for different tables(entities)?
Hello Omer,
Thank you for contacting us.
I believe that you will find the threads below very helpful. My colleagues Tsvetelina and Petko are explaining respectively how to change the header text in igGrid cellRendered event and through the TH element.
Suggestion one: http://es.infragistics.com/community/forums/p/86964/433914.aspx
Suggestion two: http://es.infragistics.com/community/forums/p/86461/431334.aspx#431334
If you have any further questions regarding this, please do not hesitate to contact me.
Looking forward to hearing from you.
Hello Zdravko,
I was hoping for a server side procedure because it would have been a hassle for me to get all the Headertext of corresponding columns from server for the desired entity because the grid is going to diplay data for different entities at runtime.
I have changed autogeneratecolumns to false now and I am building the columns myself in my action method now , so there I am setting the header Text on individual columns, The problem is resolved now. Thanks for your help time, Appreciate it.
Thank you for your reply and for sharing this solution with us. I believe that the other community members could benefit from such threads.
Let me know if I may be of further assistance.