Jun 08, 2023, 12:17 PM
[OPEN] [#1877] Grouped Datagrid loses selection by DataBind
Hi Fabrício,
I upgraded to Ext.NET 5.3. So far it works. But now it loses the selection when I work with grouping. Here is the new code.
I upgraded to Ext.NET 5.3. So far it works. But now it loses the selection when I work with grouping. Here is the new code.
Imports Ext.Net
Public Class grid2
Inherits System.Web.UI.Page
Dim aktGrid As New GridPanel
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim aktResourceManager As New ResourceManager
With aktResourceManager
.ID = "rm"
.Theme = Ext.Net.Theme.Neptune
End With
With aktGrid
.ID = "mwgrid"
.Width = 700
.Height = 350
.SelectionModel.Clear()
.View.Clear()
.Plugins.Clear()
.ColumnModel.Columns.Clear()
.Features.Clear()
.Store.Clear()
.EnableLocking = True
Dim _Store As New Store
_Store.ID = "store1"
Dim _Model As New Model
_Model.IDProperty = "Col1"
For i As Integer = 1 To 10
If i = 1 Then
_Model.Fields.Add(New ModelField("Col" & i.ToString, ModelFieldType.Int))
Else
_Model.Fields.Add(New ModelField("Col" & i.ToString, ModelFieldType.String))
End If
Next
_Store.Model.Add(_Model)
_Store.DataSource = Me.Data
.Store.Add(_Store)
With .ColumnModel
For i As Integer = 1 To 10
Dim _Col As Object
If i = 1 Then
_Col = New NumberColumn
Else
_Col = New Column
End If
_Col.ID = "Col" & i.ToString
_Col.Text = "Col" & i.ToString
_Col.DataIndex = "Col" & i.ToString
If i = 1 Then _Col.Locked = True
.Columns.Add(_Col)
Next
End With
Dim _RowSelModel As New RowSelectionModel
With _RowSelModel
.Mode = SelectionMode.Single
End With
.SelectionModel.Add(_RowSelModel)
.Features.Add(New Grouping)
Dim _View As New GridView
_View.StripeRows = True
_View.TrackOver = True
.View.Add(_View)
End With
Dim _button As New Button("Databind")
AddHandler _button.DirectEvents.Click.Event, AddressOf Click
_button.ID = "databind"
Page.FindControl("form1").Controls.Add(aktResourceManager)
Page.FindControl("form1").Controls.Add(aktGrid)
Page.FindControl("form1").Controls.Add(_button)
If Not Ext.Net.ExtNet.IsAjaxRequest Then
aktGrid.Store(0).GroupField = "Col2"
Dim RM As RowSelectionModel = aktGrid.GetSelectionModel
If RM.SelectedRows.Count = 0 Then
RM.SelectedRows.Add(New SelectedRow(5))
RM.UpdateSelection()
End If
End If
End Sub
Private Sub Click(sender As Object, e As DirectEventArgs)
aktGrid.Store(0).DataBind()
End Sub
Private ReadOnly Property Data As Object()
Get
Data = New Object() {New Object() {1, "test1", "test1", "test1", "test1", "test1", "test1", "test1", "test1", "test1"},
New Object() {2, "test1", "test1", "test1", "test1", "test1", "test1", "test1", "test1", "test1"},
New Object() {3, "test1", "test1", "test1", "test1", "test1", "test1", "test1", "test1", "test1"},
New Object() {4, "test1", "test1", "test1", "test1", "test1", "test1", "test1", "test1", "test1"},
New Object() {5, "test1", "test1", "test1", "test1", "test1", "test1", "test1", "test1", "test1"},
New Object() {6, "test1", "test1", "test1", "test1", "test1", "test1", "test1", "test1", "test1"},
New Object() {7, "test1", "test1", "test1", "test1", "test1", "test1", "test1", "test1", "test1"},
New Object() {8, "test1", "test1", "test1", "test1", "test1", "test1", "test1", "test1", "test1"},
New Object() {9, "test1", "test1", "test1", "test1", "test1", "test1", "test1", "test1", "test1"},
New Object() {10, "test1", "test1", "test1", "test1", "test1", "test1", "test1", "test1", "test1"},
New Object() {11, "test1", "test1", "test1", "test1", "test1", "test1", "test1", "test1", "test1"}}
End Get
End Property
End Class