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

Virtual Mode Cell Update

3 Answers 280 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Hesham Desouky
Top achievements
Rank 2
Hesham Desouky asked on 23 Jan 2012, 03:58 PM
Hello,

I am implementing virtual mode for WinForms RadGridView

Everything working ok except one thing, in my virtual mode implementation user may required additional data from slow data source in such case the data will not be available when grid needs the cell value.
In this case the cells displays a "Loading..." text until the data is retrieved from the slow source.

The problem is how to tell the GridView to reread the cells values to update the cells with real content.

I tried the MasterTemplate.Refresh but this cause the grid scroll returns to the top again and display the first item.

Is there any method to call to force the grid to re-read the visisble cells values without reseting the scroll?

I am using 2011 Q2 SP1


3 Answers, 1 is accepted

Sort by
0
Accepted
Julian Benkov
Telerik team
answered on 26 Jan 2012, 10:05 AM
Hi Heshman,

You should call the Update method of GridTableElement to solve this issue. Consider the sample below:

public partial class VirtualGridForm : Form
{
    private Random random = new Random((int)DateTime.Now.Ticks);
 
    public VirtualGridForm()
    {
        InitializeComponent();
         
        radGridView.VirtualMode = true;
        radGridView.CellValueNeeded += new GridViewCellValueEventHandler(radGridView_CellValueNeeded);
        radGridView.RowCount = 1000;
        radGridView.ColumnCount = 10;
    }
 
    void radGridView_CellValueNeeded(object sender, GridViewCellValueEventArgs e)
    {
        e.Value = random.Next(1000);
    }
 
    private void button1_Click(object sender, EventArgs e)
    {
        radGridView.TableElement.Update(GridUINotifyAction.DataChanged);
    }
}

I hope this helps.

Kind regards,
Julian Benkov
the Telerik team

SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

0
Hesham Desouky
Top achievements
Rank 2
answered on 29 Jan 2012, 09:38 AM
thanks for your reply,

I am implementing this solution:
var visibleRows = gridStudy.TableElement.VisualRows.Select(r=>r.RowInfo).ToArray();
gridStudy.TableElement.Update(GridUINotifyAction.DataChanged, visibleRows);

It works but I don't know whether the extra code I add to update the visible rows only enhance performanfce or not?
0
Accepted
Julian Benkov
Telerik team
answered on 01 Feb 2012, 12:02 PM
Hello Hesham,

This additional logic is not needed in virtual mode. RadGridView is optimized for this behavior and CellValueNeeded event will be fired only for the visible cells on the screen.

Kind regards,
Julian Benkov
the Telerik team

SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

Tags
GridView
Asked by
Hesham Desouky
Top achievements
Rank 2
Answers by
Julian Benkov
Telerik team
Hesham Desouky
Top achievements
Rank 2
Share this question
or