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

User interaction with the gridView

2 Answers 37 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Henri
Top achievements
Rank 1
Henri asked on 30 Apr 2014, 08:36 AM
Hi,

I am using the hierarchical Gridview as some sort of navigation tree.
Typically, the Grid is positioned on the left pane, the right pane contains detail data an more.

When the user selects a row, from any level in the grid, extra data is loaded and displayed on the right pane.
Mostly, the detail pane contains a lot more data, than is displayed in the navigation grid. Depending on the network speed, this can take a bit of time.

My problem is that the grid, used as a data navigation aid, still accepts user interaction while detail data is being retrieved from the database.

Now I have to options:
1. fetch detail data in a separate thread, and abort when the user selects another row.
2. keep the grid (navigation aid) from processing user interaction while detail data is loading.

My question is,
can user interaction with the grid be placed on the same thread, so that it has to wait for the detail data being loaded?

Thanks.

2 Answers, 1 is accepted

Sort by
0
Henri
Top achievements
Rank 1
answered on 30 Apr 2014, 02:21 PM
Hello again,

Handling SelectionChanged and setting e.Cancel=true when details are still loading solves my problem.
But calling Application.DoEvents() to force an update of a status label (indicating database is being accessed), causes a NullReferenceException in GridTableElement.OnSelectionChanged.

0
Dimitar
Telerik team
answered on 01 May 2014, 07:34 AM
Hello Henri,

Thank you for writing.

I am not sure what do you mean by place the user interaction on the same thread, but mixing treads in such way is not recommended. A simple solution would be to just to use a flag and cancel the row changing if the loading is not complete. In this case you can use the CurrentRowChanging event to cancel the change if the load is not completed:
bool loaded = false;
 
void radGridView1_CurrentRowChanging(object sender, CurrentRowChangingEventArgs e)
{
    if (!loaded)
    {
        e.Cancel = true;
    }
}

For the sake of the example I have attached a sample where the user can change the current row once every ten seconds.

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
GridView
Asked by
Henri
Top achievements
Rank 1
Answers by
Henri
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or