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

[Solved] It's Urgent !! Plz Help

2 Answers 100 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Keyur Raval
Top achievements
Rank 1
Keyur Raval asked on 21 Sep 2009, 09:27 PM
Hi,

I am trying to use Telerik Silverlight gridview and have a specific requirement.

1) Number of columns are dynamic on my gridview, which I am adding dynamically

2) On the "RowLoaded' event I want to access cell template for every column's cell for the loading row and assign some data template and data context to that ( Or simply content), previously I was using MS DataGrid and doing it as below.

 FrameworkElement element = myDataGrid.Columns[0].GetCellContent(e.Row);
 FrameworkElement datagridCell = GetParent(element, typeof(DataGridCell)); //GetParent is resursive method to get parent
DataGridCell cell = (DataGridCell)result;
cell.Content = MyDataModel for that cell;

Same thing I am trying to achieve with GridView control from Telerik . Please advise me to the appropriate direction.

Thanks

2 Answers, 1 is accepted

Sort by
0
Keyur Raval
Top achievements
Rank 1
answered on 22 Sep 2009, 01:00 PM
Any suggestions, sample code ?

Thanks

0
Ludovic Gerbault
Top achievements
Rank 1
answered on 22 Sep 2009, 04:21 PM
Well, generating dynamic columns is quite simple

Here's  a piece of code that should do the trick
for(int i=0;i<yourcolumns.Count -1;i++) 
      GridViewDataColumn column = new GridViewDataColumn() {Header = yourcolumns[i].Header, DataType = yourcolumns[i].type}; 
      YourRadGrid.Columns.Add(column);
}
 



About the Cell Template of a column, I guess it depends if your style applies to all the cells of a particular columns, in which case something like that would work :

column.CellTemplate= yourTemplate;

If the cell template depends on the row, then, in the RowLoaded Event method, try this

foreach(GridViewCellBase in e.Row.Cells)
{
        cell.Template = yourTemplate
}


Tags
GridView
Asked by
Keyur Raval
Top achievements
Rank 1
Answers by
Keyur Raval
Top achievements
Rank 1
Ludovic Gerbault
Top achievements
Rank 1
Share this question
or