I have 2 xtragrids. The first grid(Gridview1) is being populated using a standard dataset, doesn't contain many rows. What I would like to do is when the focused row of Gridview1 changes is populate the second xtragrid(Gridview2) using a linqinstantfeedbacksource based upon a cell value of Gridview1. The reason for using server mode on Gridview2 is because it will contain many rows. I am new to linq and am struggling with this. I have my data context setup using 2 tables (inventory_tbl and plants_tbl). They are linked to pull in the plantname based on the plantid stored in the inventory_tbl(simple join). Here is what I have so far:
Public Class Inventoryfrm
Private dbinventoryreceipts As New InventorySummaryDataContext
Private startup As Boolean = True
Private Sub Inventoryfrm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Me.Cursor = Cursors.WaitCursor
dbinventoryreceipts.ObjectTrackingEnabled = False
Me.Cursor = Cursors.Default
Private Sub GridView1_FocusedRowChanged(sender As Object, e As DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs) Handles GridView1.FocusedRowChanged
Dim x As Integer = GridView1.FocusedRowHandle
If Me.GridView1.IsRowLoaded(x) = True Then
InventoryInstantFeedbackSource1.KeyExpression = "ID"
GridControl2.DataSource = InventoryInstantFeedbackSource1
Private Sub InventoryInstantFeedbackSource1_DismissQueryable(sender As Object, e As DevExpress.Data.Linq.GetQueryableEventArgs) Handles InventoryInstantFeedbackSource1.DismissQueryable
Private Sub InventoryInstantFeedbackSource1_GetQueryable(sender As Object, e As DevExpress.Data.Linq.GetQueryableEventArgs) Handles InventoryInstantFeedbackSource1.GetQueryable
Dim selectedReceipts = From I In dbinventoryreceipts.Inventory_tbls _
Join P In dbinventoryreceipts.Plants_tbls On P.ID Equals I.PlantID _
Where I.IngredientID = Me.GridView1.GetFocusedRowCellValue("ID")
Order By I.ReceiptDate Ascending _
Select I.ID, I.ReceiptDate, I.ReceiptAmount, I.AmountRemaining, P.PlantName
e.QueryableSource = selectedReceipts
e.Tag = dbinventoryreceipts
My linq to sql query doesn't seem to be working for one. It is returning all the columns in the inventory_tbl, with no data, instead of just the ones I indicated in the query. Also how do I call the InventoryInstantFeedbackSource1_GetQueryable every time the focus is changed in Gridview1. Am I going about this the right way? What am I missing. Should I be approching this a different way.
Thank you for pointing this out. I now see the issue. It is caused by the fact that you are customizing Grid columns, applying grouping and creating group summaries each time a focused row is changed. Please note that these operations are pretty resource-consuming. I suggest you perform all these customizations at design-time. After I have removed this code from the GridView.FocusedRowChanged event handler, the sample project operates very fast on my computer. Would you please test it in your environment and let us know of your results?
Is your intention to post an answer to your own question?
- If so, then proceed.
- If you simply wanted to post additional information, ask for further clarification, or to just say "Thanks!", please click Leave a Comment.
- If you wish to edit your original question, please use the Edit button in the Toolbox at the top right corner of that entry.