No matter what I try I am getting a stackoverflow error on the CellValueNeeded event anytime I try to sort any of my grids.
Not sure what to do here.
David
21 Answers, 1 is accepted
I tested the described scenario using the virtual mode in RadGridView. However, I was not able to observe issues. Please, could you prepare a small project which reproduces the issue. This will allow us to investigate it in detail and provide you with further assistance. Thank you in advance.
I am looking forward to your reply.
All the best,
Julian Benkov
the Telerik team
SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).
I can reproduce the error with the following code.
Public
Class
Form1
Private
CellValueNeededCount
As
Integer
= 0
Private
CellValue
As
Integer
= -1
Private
Sub
Form1_Load(sender
As
System.
Object
, e
As
System.EventArgs)
Handles
MyBase
.Load
With
RadGridView1
.VirtualMode =
True
.Columns.Add(
"C1"
)
.Columns.Add(
"C2"
)
.Columns.Add(
"C3"
)
.AllowAddNewRow =
False
.AllowDeleteRow =
False
.AllowEditRow =
False
.ShowGroupPanel =
False
.EnableFiltering =
False
.EnableGrouping =
False
.RowCount = 1000
End
With
End
Sub
Private
Sub
RadGridView1_CellValueNeeded(sender
As
Object
, e
As
Telerik.WinControls.UI.GridViewCellValueEventArgs)
Handles
RadGridView1.CellValueNeeded
CellValueNeededCount += 1
' with 10 rows visible = 30 for unsorted,18000+ for sorted
Me
.Text = CellValueNeededCount
'**************************************************************************************************
'Swapping the following lines will cause a stack overflow exception when sort
e.Value = CellValue
'e.Value = GetValueFromDataCache(e.RowIndex, e.ColumnIndex) 'e.RowIndex seems to be undefined when sorted
'**************************************************************************************************
End
Sub
Private
Function
GetValueFromDataCache(RowIndex
As
Integer
, ColumnIndex
As
Integer
)
As
Integer
Return
RowIndex + ColumnIndex + CellValue
End
Function
Private
Sub
RadGridView1_SortChanged(sender
As
Object
, e
As
Telerik.WinControls.UI.GridViewCollectionChangedEventArgs)
Handles
RadGridView1.SortChanged
'SortDataCache(BuildOrderByText)
RadGridView1.TableElement.Update(Telerik.WinControls.UI.GridUINotifyAction.DataChanged)
End
Sub
Private
Sub
RadGridView1_SortChanging(sender
As
Object
, e
As
Telerik.WinControls.UI.GridViewCollectionChangingEventArgs)
Handles
RadGridView1.SortChanging
CellValueNeededCount = 0
'reset the count
CellValue =
CInt
(Rnd(1) * 1000)
'new number to display
End
Sub
End
Class
Indeed, RadGridView does not support filtering, sorting, and grouping in Virtual Mode. Only the UI and descriptor collections are updated. We found some issues when the RowIndex and ColumnIndex arguments are used in sorting operation. I logged the issues in our Public Issue Tracking System. Here you can find the PITS entry: Public URL. The fix will be available in one of the next releases.
Thank you for the report. Your Telerik points have been updated.
Regards,
Julian Benkov
the Telerik team
Same is true for grouping.
Can you confirm that this was indeed fixed in the latest release? I'm currently using v.2013.2.724.40
Thanks,
Wayne
Thank you for writing.
The issue in question has not yet been fixed. As said in this help article, the following operations are not support by RadGridView while in VirtualMode:
- Grouping
- Sorting
- Filtering
As with VirtualMode you need to manage your DataSource manually the grid has no direct access to it, thus these operations are impossible with the current implementation of RadGridView. You can however perform the filtering and sorting operations directly on your DataSource collection.
Let me know if you have further questions.
George
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Is any VirtualModeUserWantsToSort(ColumnIndex, Ascending) , VirtualModeUserWantsToFilter(ColumnIndex, FilterDescriptor) event available to help virtual mode implementor to reuse the existing grid filter and sort descriptor user interface?
Or as an alternative: is possible to intercept column header click to sort data and display the sort arrow to the user and to put a customized filter row above each column that the user can use to insert search criteria (and a filter operator)?
Thank you for writing back.
Currently, we do not have such example. We are considering adding such article in future, should we add it, I will let you know in this thread.
You can intercept a header cell click by using the MouseClick event of RadGridView. You can also use the FilterChanging, SortChanging events to cancel the operations and still get the sort/filter expression which you can use to filter your data source. Note that after you have filtered your data you should set the RowCount property of RadGridView in order to refresh the data.
Let me know if you have further questions.
Regards,
George
Telerik
Best regards.
Feel free to share your solutions with the community or ask, should you need further assistance. You can use our Code Library section for sharing interesting solutions with the community.
Regards,
George
Telerik
As I promised, I am getting back to you since we released an article which demonstrates how to use filtering, sorting and grouping with RadGridView and Virtual Mode. You can find the article on the following address: High Performance with RadGridView and Virtual Mode including Filtering, Sorting and Grouping.
Do not hesitate to let me know, should you have any questions.
Regards,
George
Telerik
I think in the same way i adapted to my orm can be done for who using relational databases / datatables / iqueryable.
It works fine.
Thank you very much, i did not have enough grid knowledge to be able to imagine this solution, i really appreciated.
I can apply this to a few projects immediately.
I am glad that you were able to integrate this article into your projects.
Do not hesitate to write back, should you require further assistance,
Regards,
George
Telerik
I downloaded your "High Performance with RadGridView and Virtual Mode including Filtering, Sorting and Grouping" sample and have been experimenting with it for a few days. It's a very nice sample. One thing I noticed is that if there is a group, sorting of the non-grouped columns no longer works. Is this something that is even possible to implement? If so, I could use a little direction.
Thanks,
Bob
Thank you for writing.
This custom solution does not handle this particular case. However it is possible to implement such functionality. What needs to be done is to return proper value in the GetItemKey method in the VirtualGroupBuilder class. In addition you need to set the PagingBeforeGrouping property to false. You should create a dictionary that holds all items indexes as well (this just speeds up the process because using the IndexOf method is slow in this case).
I have attached an updated version of the project. To test this case just group by using the "id" column and then sort by "Name".
I hope this will be useful.
Regards,
Dimitar
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Hello Dimitar,
when I try to sort by Name, I get an exception:
System.InvalidOperationException non è stata gestita
HResult=-2146233079
Message=Sorting operation is not supported in VirtualMode.
Source=Telerik.WinControls.GridView
StackTrace:
in Telerik.WinControls.UI.GridViewSortDescriptorCollection.InsertItem(Int32 index, SortDescriptor item)
in System.Collections.ObjectModel.Collection`1.Add(T item)
in Telerik.WinControls.UI.GridViewColumn.Sort(RadSortOrder sortOrder,
Boolean
multiSortMode)
in Telerik.WinControls.UI.GridHeaderCellElement.Sort(RadSortOrder sortOrder)
in Telerik.WinControls.UI.GridHeaderRowBehavior.OnMouseUp(MouseEventArgs e)
in Telerik.WinControls.UI.BaseGridBehavior.OnMouseUp(MouseEventArgs e)
in Telerik.WinControls.UI.RadGridView.OnMouseUp(MouseEventArgs e)
in System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
in System.Windows.Forms.Control.WndProc(Message& m)
in System.Windows.Forms.ScrollableControl.WndProc(Message& m)
in Telerik.WinControls.RadControl.WndProc(Message& m)
in System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
in System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
in System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
in System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
in System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
in System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
in System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
in System.Windows.Forms.Application.Run(Form mainForm)
in VirtualRadGridViewSortingFiltering.Form.Program.Main() in C:\Users\Filippo\Documents\Visual Studio 2015\Projects\cb6cbbe6-2b56-4de1-83a1-24155c9e598a_virtualradgridview\VirtualRadGridViewSortingFiltering.Form\Program.cs:riga 19
in System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly,
String
[] args)
in System.AppDomain.ExecuteAssembly(
String
assemblyFile, Evidence assemblySecurity,
String
[] args)
in Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
in System.Threading.ThreadHelper.ThreadStart_Context(
Object
state)
in System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback,
Object
state,
Boolean
preserveSyncCtx)
in System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback,
Object
state,
Boolean
preserveSyncCtx)
in System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback,
Object
state)
in System.Threading.ThreadHelper.ThreadStart()
InnerException:
I don't understand if I missing something to do...
Thank you for your sample,
Filippo
Hi FIlippo, this happens to the new version of the grid, they are aware of the problem and they are working on this, look at the following http://feedback.telerik.com/Project/154/Feedback/Details/166550-add-radgridview-add-means-for-a-virtual-grid-to-go-round-the-current-sort-fil , the eta is Q3 2015.
Best Regards
Thank you for this info,
I'm trying to use EF 6.3 to access a SQL Server Database but I have a lot of performance issue if I have to call DBSet(T).Load just to get data sources for data-bounded RadGridView's templates.
What I need is a Hierarchical GridView in virtual mode (also for childs...) and Sort, Group and Filter enabled functionalities.
I'll try using Load-On-Demand but I don't know if "Add New Row" will work for children in hierarchy.
Please consider this scenario for a future sample that will help a developer to solve performance issues quickly.
Best of all will be if Telerik will implement this scenario inside RadGridView, for example setting DBSet(Of T) as datasource and loading data when needed.
Best regards,
Filippo.
Thank you for writing.
I have logged a feature request for this in our Feedback Portal. You can track the item for status changes and add your vote for it here.
When you are using load on demand hierarchy only the firs template is bound to the grid. If you want to add new rows, you should use the UserAddedRow and manually add the row to the data source. For example:
DataTable child =
new
DataTable();
void
radGridView1_UserAddedRow(
object
sender, GridViewRowEventArgs e)
{
child.Rows.Add(e.Row.Cells[0].Value, e.Row.Cells[1].Value);
radGridView1.Templates[0].Refresh();
}
Your Telerik Points have been updated for this report.
Should you have any other questions do not hesitate to ask.
Regards,
Dimitar
Telerik
Hi Dimitar,
I found another solution: I don't use load on demand hierarchy, instead I use databound hierarchy BUT... I eager load child entities in my DbContext in the ChildViewExpanding event.
This trick lets me demand load entities using entity framework instead RadGridView.
My solution is just more bit tricky due to other performance issues but this is the main idea.
Now I have another problem because I think there is a bug in RadGridView. Please see my Bug Report ID:968829. I have a Data Exception that is impossible for me to understand.
Best Regards,
Filippo
Since you have opened a support ticket, you can continue to discuss this case with the support staff there (where you can exchange projects) and once a resolution is reached, this forum thread can be updated.
Do not hesitate to contact us if you have other questions.
Regards,
Dimitar
Telerik