views:

375

answers:

2

Hi,

I would like to do something similar what we do in ASP.NET where we parse through all the rows in a GridView and assign a particular value to a particular cell in a row which has a matching TaskId as the current Id.

This has to happen in a Tick function of a Dispatcher Timer object. Since I have a Start Timer button Column for every row in a GridView. Upon a particular row's Start Timer Button click, I have to start its timer and display in a cell in that row. Similarly there can be multiple timers running in parallel.

For this I need to be able to check the task Id of the particular task and keep updating the cell values with the updated time in all of the tasks that have a Timer Started.

TimeSpan TimeRemaining = somevalue; string CurrentTaskId = "100"; foreach(GridViewRow row in RadGridView1.Rows) // Here I tried RadGridView1.ChildrenOfType() as well but it has null { if( (row.DataContext as Task).TaskId == CurrentTaskId ) row.Cells[2].Content = a.TaskTimeRemaining.ToString(); }

Can someone please let me know how do I get this functionality using the Telerik RadGridView?

Cheers, Syed.

A: 

this works for me - using Telrik WinControls Q2 2009. I have this in the tick event of a timer.

foreach (GridViewRowInfo row in this.radGridView1.MasterGridViewTemplate.Rows)
{
    if (row.Cells["colId"].Value.ToString() == CurrentTaskId)
    {
        row.Cells["colTimerValue"].Value = a.TaskTimeRemaining.ToString();
    }
}
Barry
Barry I have an issue here. My timer has an incrementor value set to 1 second. When the timer is started, if I scroll to the right end of my GridView and scroll back to the left end, it blanks my timer cell and refreshes the next second with the next Tick value.But the issue is when I have stopped my timer it displays the current value of the timer. Here if I repeat the scroll to the right and back, the cell loses its value and shows blank :(.Did you face the same issue? If yes any solution or reasoning why it happens so?Cheers,Syed
Syed
Syed, I'm afraid I haven't used the Silverlight controls as yet so I'm not best placed to comment. I presume you have tried the Telerik site? http://www.telerik.com/help/silverlight/radgridview-row-details-programming.html
Barry
A: 

Thanks anyways Barry :)

Syed
Im using a Silverlight RadGridView and your code I guess is for a Winforms GridView and both seem to be different.foreach(var dataItem in this.RadGridView2.Items) { var firstRow = this.RadGridView2.ItemContainerGenerator.ContainerFromItem(dataItem) as GridViewRow; TaskInfo ti = firstRow.DataContext as TaskInfo; if (ti.TaskId == a.TaskId) firstRow.Cells[2].Content = a.TaskTimeRemaining.ToString();}
Syed
Barry I have an issue here. My timer has an incrementor value set to 1 second. When the timer is started, if I scroll to the right end of my GridView and scroll back to the left end, it blanks my timer cell and refreshes the next second with the next Tick value.But the issue is when I have stopped my timer it displays the current value of the timer. Here if I repeat the scroll to the right and back, the cell loses its value and shows blank :(.Did you face the same issue? If yes any solution or reasoning why it happens so?Cheers,Syed
Syed