Hello,
I use auto generating of columnes in wdg. In pageload i bind the grid to the dataview. How do I set css for those columns? I tried to do that in databound event, but it doesn't find the columns. One more point - I need to trim the string in the column. In uwg it was possible like this
protected void UltraWebGrid1_InitializeRow(object sender, RowEventArgs e) { e.Row.Cells[0].Value = e.Row.Cells[0].Value.ToString().TrimEnd(); }
But in wdg it's allowed only for unbound columnes. Any help?
Ok, as for auto generated columns i found useful but mostly discouraging information here - http://es.infragistics.com/community/forums/t/51770.aspx .
Summarizing it - it's impossible to access autogeneratedcolumns directly (THOUGH IT WOULD BE GREAT - LIKE WE CAN ACCESS BOUND AND BOUND COLUMNS, MAKE ANOTHER PROPERTY - AUTOGENERATEDCOLUMNS).
But it's possible to access it from the rows like Rows[0].Items[i].Column (thanks to Werner). However, the tricky point is that it's possible not from all event handlers. For example from data bound it yet didn't see the new columns.
The best solution I found so far - and the working one - to init DataSource for grid and after that to set properties for Columns.
But the issue about changing values is still unresolved. Perhaps it's possible to use value format property, I'm not yet sure.
Yes, one more piece of magic.
Let's say I call function checkIniting in the end of Page_Load (DataSort is already assigned (in my case, DataView)).
If I use this code -
private void checkIniting() { Infragistics.Web.UI.GridControls.GridRecordItemCollection gric = this.wdgTypes.Rows[0].Items; foreach (Infragistics.Web.UI.GridControls.GridRecordItem gri in gric) { gri.Column.CssClass = "dgColumn"; }
}
nothing happens.
However, this code
private void checkIniting() { Infragistics.Web.UI.GridControls.GridRecordItemCollection gric = this.wdgTypes.Rows[0].Items; for (int i = 0; i < gric.Count; i++) { gric[i].Column.CssClass = "dgColumn"; }
works OK.
Perhaps I don't understand something about collections, but still this difference is strange.