It appears that the webgrid (v8.3) looses track of the rows when in Ajax mode and either scrolled past the off-band fetch or grouped by dragging column to the top in OutlookGroup mode.
I have a ClickCellButton event hooked up on each row to add items into the shopping cart. When I scroll or group the ClickCellButton event returns completely different item than the one in the row clicked on in the Dim TestName As String = e.Cell.Row.Cells(3).Value.ToString
statement
Is there a way to fix this? for now I just removed the Ajax and OutllokGroup from the grid. Not very elegant solution.
Thanks,
Jakub
Jakub,
For most XmlLoadOnDemandType values, WebGrid does not remember what rows were already loaded when you post back. So, the result you've described is generally expected.
There are two possible solutions for this.
The first is to process information client-side, rather than server-side. By avoiding the postback, you avoid the scenario of the grid resetting its rows in the first place. Obviously, this is an option only if you're able to process your functionality on the client. In your scenario, you might be able to use the client-side ClickCellButton event, rather than the server-side event.
The second option is to change the DisplayLayout.XmlLoadOnDemandType property to Accumulative (Infragistics.WebUI.UltraWebGrid XmlLoadOnDemandType.Accumulative). With this setting, any rows that were loaded into the grid remain loaded when you postback.
That works reasonably well, but now the rows are unsorted when grouped. How can I make them sorted (the SQL statement IS sorted) while keeping the order of the rows.
e.Layout.Bands(0).SortedColumns.Add(
"TestCode") seems to break the order.
thanks
When you use Outlook group-by, the grid sorts your data by the columns by which you grouped - in other words, grouping is tightly coupled to sorting. So, if you've sorted your data when retrieving it from the database, this sort order likely will not be maintained when you group by a column other than the one by which you sorted.
To address this, use the grid's sorting capabilities to sort your data, in addition to grouping.