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

Cellvalue doesn't retain while editing for dynamically added columns

1 Answer 45 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Sharada
Top achievements
Rank 1
Sharada asked on 22 Dec 2010, 11:56 AM
Hi

 I am using TreeListView. 
 I am adding columns dynamically at runtime

GridViewDataColumn column;

for (int icnt = 1; icnt < ts.Days; icnt++) 

{

column = new GridViewDataColumn();
column.UniqueName = "key" + icnt.ToString();
column.IsReadOnly = false;
RadTreeListView1.Columns.Add(column);

}

I am populating the cell data in RadTreeListView1_RowLoaded event.

var row = e.Row as TreeListViewRow;

foreach (GridViewCell cell in row.Cells)

{

 if (cell.IsLoaded)
{

DateTime dates;

if (DateTime.TryParse(cell.Column.Header.ToString(), out dates))
{

 string filter = "dates = '#" + dates.ToShortDateString().ToString() + "#'";

 DataRow[] dr = lobjdt.Select(filter);

 if (dr != null && dr.Length > 0)

{

cell.Content = dr[0]["hours"].ToString();
 

}

}

}

}


But I am facing one more diffrent problem.
I want to edit cells of cloumns which I have added dynamically.
I am able to click and edit the data ... but data gets disappeares when user leave the cell and click somewhere else in the window.

Editing is working correctly in static clumns.
Am I missing anything while adding columns ?

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 27 Dec 2010, 03:51 PM
Hello Sharada,

May you provide a bit more details about the data source of the RadTreeListView ? What is its type ? Furthermore, it is not recommended to work directly with the content of the visual elements as they get recycled on scrolling. It is better to bind the corresponding column to a property of your business object.
However, in order to provide you with an appropriate for you case solution, I would need more information about your project. Any relevant information would be helpful.
 

Greetings,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
Tags
TreeListView
Asked by
Sharada
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or