Jun 02, 2023, 10:37 AM
[CLOSED] Locked Datagrid loses selection by DataBind
I have a new problem with locked grids.
After the "Grid.DataBind" the grid loses the selection.
If you comment out If i = 1 Then _Col.Locked = True again and then select a row and click on Databind , everything works. Why?
After the "Grid.DataBind" the grid loses the selection.
If you comment out If i = 1 Then _Col.Locked = True again and then select a row and click on Databind , everything works. Why?
Imports Ext.Net
Public Class grid
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
Dim _ToolTip As New ToolTip
_ToolTip.ID = "mwtooltip"
_ToolTip.Target = "={#{mwgrid}.getView().el}"
_ToolTip.Delegate = ".x-grid-cell"
_ToolTip.TrackMouse = False
_ToolTip.Listeners.Show.Handler = "onShow(this, #{mwgrid});"
Dim _Script As String = " <script> "
_Script &= " var onShow = function (toolTip, grid) { "
_Script &= " var view = grid.getView(),"
_Script &= " store = grid.getStore(),"
_Script &= " record = view.getRecord(view.findItemByChild(toolTip.triggerElement)),"
_Script &= " column = view.getHeaderByCell(toolTip.triggerElement),"
_Script &= " data = record.get(column.dataIndex);"
_Script &= " toolTip.update(data);"
_Script &= "};"
_Script &= " </script>"
Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "onShow", _Script)
With aktGrid
.ID = "mwgrid"
.Width = 700
.Height = 350
.SelectionModel.Clear()
.View.Clear()
.Plugins.Clear()
.ColumnModel.Columns.Clear()
.Features.Clear()
.Store.Clear()
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)
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(_ToolTip)
Page.FindControl("form1").Controls.Add(_button)
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
Last edited by fabricio.murta; Jul 08, 2023 at 5:25 PM.