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

how to use RadWaitingBarElement in RadGridView

2 Answers 284 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tomas Novak
Top achievements
Rank 1
Tomas Novak asked on 23 May 2010, 11:14 AM

Hello.

Please, could you give me an adwace how to use RadWaitingBarElement in RadGridView and run this element. I have try used it in cell_formating, but it do not work.

(it is trial Version: 2010.1 504 , C#, vs 2008 express)

Thank you for advice or source code.

void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)   
{   
if (e.CellElement.RowIndex < 0) return;   
if (((GridViewDataColumn)e.CellElement.ColumnInfo).FieldName == "test")   
{   
RadWaitingBarElement element = new RadWaitingBarElement();   
element.StretchHorizontally = true;   
element.StretchVertically = true;   
element.waitingTimer = this.timer1;//timer is running   
e.CellElement.Children.Add(element);   
}  

2 Answers, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 27 May 2010, 07:00 AM
Hello Tomas Novak,

Thank you for contacting us.

I would suggest that you use RadWaitingBar control instead of RadWaitingBarElement. Using the control allows you to start waiting without any additional timers. Please consider the code snippet:

private void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
    GridDataCellElement cell = e.CellElement as GridDataCellElement;
    GridViewDataColumn column = cell.ColumnInfo as GridViewDataColumn;
 
    if (cell == null || column == null || cell.RowIndex < 0) return;
    if (column.FieldName == "test")
    {
        bool waitingBarAdded = false;
        foreach (RadElement element in cell.Children)
        {
            RadHostItem hostItem = element as RadHostItem;
            if (hostItem != null)
            {
                RadWaitingBar hostedControl = hostItem.HostedControl as RadWaitingBar;
                if (hostedControl != null)
                {
                    waitingBarAdded = true;
                }
            }
        }
        if (!waitingBarAdded)
        {
            RadWaitingBar waitingBar = new RadWaitingBar();
            waitingBar.WaitingStep = 1;
            waitingBar.WaitingSpeed = 1;
            waitingBar.StartWaiting();
 
            RadHostItem hostItem = new RadHostItem(waitingBar);
            e.CellElement.Children.Add(hostItem);
        }
    }
}

RadWaitingBar uses an internal timer and you only need to call the StartWaiting() method in order to make it running. You do not need an additional timer to make the RadWaitingBar move. Please describe your exact scenario and why you need an external timer. This scenario may require a custom solution.

A second approach is to use RadProgressBarElement. You can see an example in our Examples application, section GridView >> Column Types.

Best regards,
Alexander
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Tomas Novak
Top achievements
Rank 1
answered on 05 Jun 2010, 07:13 PM

This is exactly what I was looking for.
 For me your code works exelent so external timer will not be needed.

Thank very much.

Tomas

 

Tags
GridView
Asked by
Tomas Novak
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Tomas Novak
Top achievements
Rank 1
Share this question
or