Jan 22, 2013, 3:03 AM
[CLOSED] Grid selection event "code-behind" there are no RowSelect.Event
I try to read forums post and follow: http://forums.ext.net/showthread.php...nel-CodeBehind
rsm.DirectEvents.RowSelect.Event += SelModel_RowSelect;
There are no RowSelect
When I change to use "AddHandler GridPanel1.DirectEvents.SelectionChange.Event, AddressOf WebTestEvt" there are event trigger "WebTestEvt are Fire", but return result is Text "record.getID()" but not the id value and i think the problem may come from Param Mode, so that I change to "Raw" and the result is No any event trigger.
rsm.DirectEvents.RowSelect.Event += SelModel_RowSelect;
There are no RowSelect
When I change to use "AddHandler GridPanel1.DirectEvents.SelectionChange.Event, AddressOf WebTestEvt" there are event trigger "WebTestEvt are Fire", but return result is Text "record.getID()" but not the id value and i think the problem may come from Param Mode, so that I change to "Raw" and the result is No any event trigger.
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="frmGridPanel.aspx.vb" Inherits="prjExtNetTest.frmGridPanel" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Store ID="Store1" runat="server">
</ext:Store>
<ext:Store ID="Store2" runat="server">
</ext:Store>
</div>
<ext:GridPanel ID="GridPanel1" runat="server" Height="300" Title="Grid1"
StoreID="Store1">
</ext:GridPanel>
<ext:GridPanel ID="GridPanel2" runat="server" Height="300" Title="Grid2" StoreID="Store2">
<SelectionModel>
<ext:RowSelectionModel runat="server" Mode="Single" ID="ctl17">
<DirectEvents>
<Select OnEvent="WebTestEvt" Buffer="250">
<ExtraParams>
<ext:Parameter Name="value" Value="record.getId()" Mode="Raw" />
</ExtraParams>
</Select>
</DirectEvents>
</ext:RowSelectionModel>
</SelectionModel>
</ext:GridPanel>
<ext:Button ID="Button1" runat="server" Text="Submit" />
<br />
<ext:Label ID="Label1" runat="server">
</ext:Label>
</form>
</body>
</html>
Public Class frmGridPanel
Inherits System.Web.UI.Page
Private mobjLstOfUser As List(Of clsExample)
Private mobjExtNet As New clsExtNetModule
Private mobjExtNet2 As New clsExtNetModule
Private Sub LoadData()
Dim objNew As clsExample
Dim i As Integer
mobjLstOfUser = New List(Of clsExample)
For i = 0 To 10
objNew = New clsExample
objNew.UserID = i
objNew.UserCode = "User" & i
objNew.ChineseName = "ChineseName" & i
objNew.EnglishName = "EnglishName" & i
objNew.EnglishAddress = "Address" & i
mobjLstOfUser.Add(objNew)
Next
mobjLstOfUser = mobjLstOfUser
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
mobjExtNet.ExtNetStore = Store1
mobjExtNet.ExtNetGridPanel = GridPanel1
mobjExtNet2.ExtNetStore = Store2
mobjExtNet2.ExtNetGridPanel = GridPanel2
Dim objPar As New Ext.Net.Parameter
objPar.Value = "record.getId()"
objPar.Name = "value"
RemoveHandler GridPanel1.DirectEvents.SelectionChange.Event, AddressOf WebTestEvt
GridPanel1.DirectEvents.SelectionChange.ExtraParams.Add(objPar)
AddHandler GridPanel1.DirectEvents.SelectionChange.Event, AddressOf WebTestEvt
If Not IsPostBack Then
LoadDataToGrid()
End If
End Sub
Public Sub WebTestEvt(sender As Object, e As Ext.Net.DirectEventArgs)
Label1.Text = e.ExtraParams("value").ToString
End Sub
Protected Sub Button1_DirectClick(sender As Object, e As Ext.Net.DirectEventArgs) Handles Button1.DirectClick
LoadDataToGrid()
End Sub
Private Sub LoadDataToGrid()
LoadData()
mobjExtNet.FillLstOfDataToGridPanel(mobjLstOfUser, "UserCode,ChineseName,EnglishName", "UserID", True)
mobjExtNet2.FillLstOfDataToGridPanel(mobjLstOfUser, "UserCode,ChineseName,EnglishName", "UserID", True)
End Sub
End Class
Imports Ext.Net
Public Class clsExtNetModule
#Region "Handle List Of Name And Property"
Public Class clsNameAndProperty
Private m_Name As String
Private m_PropertyType As System.Type
Private m_ExtNetModelType As Ext.Net.ModelFieldType
Public Property Name As String
Get
Return m_Name
End Get
Set(value As String)
m_Name = value
End Set
End Property
Public Property PropertyType As System.Type
Get
Return m_PropertyType
End Get
Set(value As System.Type)
m_PropertyType = value
End Set
End Property
Public Property ExtNetModelType As Ext.Net.ModelFieldType
Get
Return m_ExtNetModelType
End Get
Set(value As Ext.Net.ModelFieldType)
m_ExtNetModelType = value
End Set
End Property
End Class
Public Shared Function getListOfProperty(ByRef item As Object) As List(Of clsNameAndProperty)
Dim objLstOf As New List(Of clsNameAndProperty)
Dim objNameAndProp As clsNameAndProperty
For Each p As System.Reflection.PropertyInfo In item.GetType().GetProperties()
If p.CanRead Then
objNameAndProp = New clsNameAndProperty
objNameAndProp.Name = p.Name
If p.GetValue(item, Nothing) Is Nothing Then
objNameAndProp.PropertyType = p.PropertyType
Else
objNameAndProp.PropertyType = p.GetValue(item, Nothing).GetType
End If
objNameAndProp.ExtNetModelType = MappingType(objNameAndProp.PropertyType)
objLstOf.Add(objNameAndProp)
End If
Next
Return objLstOf
End Function
''http://www.developerfusion.com/tools/convert/csharp-to-vb/?batchId=5785c1ad-c852-4294-a67d-8615dc7847bb
Public Shared Function MappingType(type As Type) As Ext.Net.ModelFieldType
If type = GetType(String) Then
Return Ext.Net.ModelFieldType.String
End If
If type = GetType(DateTime) Then
Return Ext.Net.ModelFieldType.Date
End If
If type = GetType(Integer) Then
Return Ext.Net.ModelFieldType.Int
End If
If type = GetType(Int16) Then
Return Ext.Net.ModelFieldType.Int
End If
If type = GetType(Double) Then
Return Ext.Net.ModelFieldType.Float
End If
If type = GetType(Boolean) Then
Return Ext.Net.ModelFieldType.Boolean
End If
Return Ext.Net.ModelFieldType.Auto
End Function
#End Region
Private WithEvents mExtNetGridPanel As Ext.Net.GridPanel
Private WithEvents mExtNetStore As Ext.Net.Store
Private WithEvents mExtNetCombox As Ext.Net.ComboBox
Public Event UnloadGridPanel()
Public Event PreRendGridPanel()
Public Property ExtNetStore As Ext.Net.Store
Get
Return mExtNetStore
End Get
Set(value As Ext.Net.Store)
mExtNetStore = value
End Set
End Property
Public Property ExtNetGridPanel As Ext.Net.GridPanel
Get
Return mExtNetGridPanel
End Get
Set(value As Ext.Net.GridPanel)
mExtNetGridPanel = value
End Set
End Property
Public Property ExtNetCombox As Ext.Net.ComboBox
Get
Return mExtNetCombox
End Get
Set(value As Ext.Net.ComboBox)
mExtNetCombox = value
End Set
End Property
Public Sub SetVisibleGridPanelColByName(Optional ByVal strColName As String = Nothing)
End Sub
Public Shared Function FillLstOfObjectToModel(ByVal objLstOfProp As List(Of clsNameAndProperty), Optional ByVal strIDProperty As String = Nothing) As Ext.Net.Model
Dim objModel As New Ext.Net.Model
objModel.Fields.Clear()
For i = 0 To objLstOfProp.Count - 1
If objLstOfProp(i).ExtNetModelType = Ext.Net.ModelFieldType.Date Then
objModel.Fields.Add(objLstOfProp(i).Name, objLstOfProp(i).ExtNetModelType)
Else
objModel.Fields.Add(objLstOfProp(i).Name, objLstOfProp(i).ExtNetModelType)
End If
Next i
If Not strIDProperty Is Nothing Then
objModel.IDProperty = strIDProperty
End If
Return objModel
End Function
Public Sub FillLstOfDataToGridPanel(Of t)(ByVal objLstOf As List(Of t), Optional ByVal strShowHideColNameList As String = Nothing, Optional ByVal strIDProperty As String = Nothing, Optional blnTIsShowFIsHide As Boolean = False, Optional strColumnAlias As String = Nothing )
Dim objLstOfProp As List(Of clsNameAndProperty)
Dim objModel As New Ext.Net.Model
Dim objExtCol As Ext.Net.Column
Dim objExtDateCol As Ext.Net.DateColumn
Dim i As Integer
Dim blnShowIt As Boolean
Dim strSplit() As String
Dim strText As String
Dim strAlias() As String
'objLstOfProp = getListOfProperty(objLstOf.GetType.GetProperty("Item"))
'objLstOfProp = getListOfProperty(objLstOf.GetType.GetProperty("Item").PropertyType)
If objLstOf.Count < 1 Then
mExtNetStore.Reader.Clear()
objModel.Fields.Clear()
mExtNetGridPanel.RemoveAllColumns()
Exit Sub
End If
objLstOfProp = getListOfProperty(objLstOf(0))
'mExtNetStore.Reader.Clear()
mExtNetStore.DataSource = objLstOf
'mExtNetGridPanel.SelectionModel.Clear()
mExtNetGridPanel.RemoveAllColumns()
objModel = FillLstOfObjectToModel(objLstOfProp, strIDProperty)
If mExtNetGridPanel.StoreID Is Nothing OrElse mExtNetGridPanel.StoreID.Trim = "" Then
mExtNetGridPanel.StoreID = mExtNetStore.ID
End If
strAlias = Split(strColumnAlias, ",")
strSplit = Split(strShowHideColNameList, ",")
For i = 0 To objLstOfProp.Count - 1
blnShowIt = False
If strShowHideColNameList Is Nothing OrElse strShowHideColNameList.Trim = "" Then
blnShowIt = True
Else
Dim query = From obj As String In strSplit Where obj = objLstOfProp(i).Name.Trim
If query.Count > 0 Then
If blnTIsShowFIsHide = True Then
blnShowIt = True
Else
blnShowIt = False
End If
End If
End If
Dim strPropertyName As String
strPropertyName = objLstOfProp(i).Name
strText = ""
If strColumnAlias Is Nothing OrElse strColumnAlias.Trim = "" Then
strText = strPropertyName
Else
strText = strPropertyName
Dim CheckEqu As Char() = New Char() {"="}
Dim AliasQuery = From objAlias As String In strAlias Where objAlias.Split("=")(0).Trim = strPropertyName.Trim
If AliasQuery.Count > 0 Then
For Each objResult In AliasQuery
strText = objResult.ToString.Split("=")(1)
Next
End If
End If
If blnShowIt = True Then
If objLstOfProp(i).ExtNetModelType = Ext.Net.ModelFieldType.Date Then
objExtDateCol = New Ext.Net.DateColumn
objExtDateCol.Text = strText ''objLstOfProp(i).Name
objExtDateCol.DataIndex = objLstOfProp(i).Name
objExtDateCol.Format = "yyyy/MM/dd"
mExtNetGridPanel.AddColumn(objExtDateCol)
Else
objExtCol = New Ext.Net.Column
objExtCol.Text = strText ''objLstOfProp(i).Name
objExtCol.DataIndex = objLstOfProp(i).Name
mExtNetGridPanel.AddColumn(objExtCol)
End If
End If
Next
mExtNetStore.Model.Clear()
mExtNetStore.Model.Add(objModel)
mExtNetStore.RebuildMeta()
mExtNetStore.DataBind()
'mExtNetGridPanel.Reconfigure()
mExtNetGridPanel.DataBind()
mExtNetGridPanel.Render()
'mExtNetGridPanel.DoLayout()
End Sub
Public Shared Function ExtControlValue(ByVal objTxt As Ext.Net.TextField) As Object
Dim RetValue = Nothing
If objTxt Is Nothing OrElse objTxt.Text Is Nothing OrElse objTxt.Text.Trim = "" Then
RetValue = Nothing
Else
RetValue = objTxt.Text
End If
Return RetValue
End Function
Public Shared Function ExtControlValue(ByVal objCbo As Ext.Net.ComboBox) As Object
Dim RetValue = Nothing
If objCbo Is Nothing OrElse objCbo.SelectedItem Is Nothing Then
RetValue = Nothing
Else
RetValue = objCbo.SelectedItem.Value
End If
Return RetValue
End Function
Public Sub FillLstOfDataToCombox(Of t)(ByVal objLstOf As List(Of t), ByVal strValueField As String, ByVal strDisplayField As String, Optional ByVal strIDProperty As String = Nothing)
Dim objLstOfProp As List(Of clsNameAndProperty)
Dim objModel As New Ext.Net.Model
If objLstOf.Count < 1 Then
mExtNetStore.Reader.Clear()
objModel.Fields.Clear()
mExtNetCombox.Items.Clear()
Exit Sub
End If
mExtNetCombox.ValueField = strValueField
mExtNetCombox.DisplayField = strDisplayField
objLstOfProp = getListOfProperty(objLstOf(0))
mExtNetStore.DataSource = objLstOf
objModel = FillLstOfObjectToModel(objLstOfProp, strIDProperty)
If mExtNetCombox.StoreID Is Nothing OrElse mExtNetCombox.StoreID.Trim = "" Then
mExtNetCombox.StoreID = mExtNetStore.ID
End If
mExtNetStore.Model.Clear()
mExtNetStore.Model.Add(objModel)
mExtNetStore.RebuildMeta()
mExtNetStore.DataBind()
'mExtNetCombox.Render()
End Sub
End Class
Public Class clsExample
Private m_UserID As Nullable(Of Integer)
Private m_UserCode As String
Private m_Password As String
Private m_ChineseName As String
Private m_EnglishName As String
Private m_NickName As String
Private m_Sex As String
Private m_DOB As Date
Private m_IDCardNo As String
Private m_PassportNo As String
Private m_Nation As String
Private m_ChineseAddress As String
Private m_EnglishAddress As String
Private m_OtherAddress1 As String
Private m_OtherAddress2 As String
Private m_Telephone As String
Private m_Mobile As String
Private m_EMail As String
Private m_BankAccount As String
Private m_BankName As String
Private m_BankAccountName As String
Private m_Marital As String
Private m_Photo As String
Private m_CustomerField1 As String
Private m_CustomerField2 As String
Private m_CustomerField3 As String
Private m_CustomerField4 As String
Private m_CustomerField5 As String
Private m_CreateDate As Date
Private m_CreateBy As String
Private m_UpdateDate As Date
Private m_UpdateBy As String
Private m_MarkDel As Nullable(Of Integer)
Public Property UserID As Nullable(Of Integer)
Get
Return m_UserID
End Get
Set(value As Nullable(Of Integer))
m_UserID = value
End Set
End Property
Public Property UserCode As String
Get
Return m_UserCode
End Get
Set(value As String)
m_UserCode = value
End Set
End Property
Public Property Password As String
Get
Return m_Password
End Get
Set(value As String)
m_Password = value
End Set
End Property
Public Property ChineseName As String
Get
Return m_ChineseName
End Get
Set(value As String)
m_ChineseName = value
End Set
End Property
Public Property EnglishName As String
Get
Return m_EnglishName
End Get
Set(value As String)
m_EnglishName = value
End Set
End Property
Public Property NickName As String
Get
Return m_NickName
End Get
Set(value As String)
m_NickName = value
End Set
End Property
Public Property Sex As String
Get
Return m_Sex
End Get
Set(value As String)
m_Sex = value
End Set
End Property
Public Property DOB As Date
Get
Return m_DOB
End Get
Set(value As Date)
m_DOB = value
End Set
End Property
Public Property IDCardNo As String
Get
Return m_IDCardNo
End Get
Set(value As String)
m_IDCardNo = value
End Set
End Property
Public Property PassportNo As String
Get
Return m_PassportNo
End Get
Set(value As String)
m_PassportNo = value
End Set
End Property
Public Property Nation As String
Get
Return m_Nation
End Get
Set(value As String)
m_Nation = value
End Set
End Property
Public Property ChineseAddress As String
Get
Return m_ChineseAddress
End Get
Set(value As String)
m_ChineseAddress = value
End Set
End Property
Public Property EnglishAddress As String
Get
Return m_EnglishAddress
End Get
Set(value As String)
m_EnglishAddress = value
End Set
End Property
Public Property OtherAddress1 As String
Get
Return m_OtherAddress1
End Get
Set(value As String)
m_OtherAddress1 = value
End Set
End Property
Public Property OtherAddress2 As String
Get
Return m_OtherAddress2
End Get
Set(value As String)
m_OtherAddress2 = value
End Set
End Property
Public Property Telephone As String
Get
Return m_Telephone
End Get
Set(value As String)
m_Telephone = value
End Set
End Property
Public Property Mobile As String
Get
Return m_Mobile
End Get
Set(value As String)
m_Mobile = value
End Set
End Property
Public Property EMail As String
Get
Return m_EMail
End Get
Set(value As String)
m_EMail = value
End Set
End Property
Public Property BankAccount As String
Get
Return m_BankAccount
End Get
Set(value As String)
m_BankAccount = value
End Set
End Property
Public Property BankName As String
Get
Return m_BankName
End Get
Set(value As String)
m_BankName = value
End Set
End Property
Public Property BankAccountName As String
Get
Return m_BankAccountName
End Get
Set(value As String)
m_BankAccountName = value
End Set
End Property
Public Property Marital As String
Get
Return m_Marital
End Get
Set(value As String)
m_Marital = value
End Set
End Property
Public Property Photo As String
Get
Return m_Photo
End Get
Set(value As String)
m_Photo = value
End Set
End Property
Public Property CustomerField1 As String
Get
Return m_CustomerField1
End Get
Set(value As String)
m_CustomerField1 = value
End Set
End Property
Public Property CustomerField2 As String
Get
Return m_CustomerField2
End Get
Set(value As String)
m_CustomerField2 = value
End Set
End Property
Public Property CustomerField3 As String
Get
Return m_CustomerField3
End Get
Set(value As String)
m_CustomerField3 = value
End Set
End Property
Public Property CustomerField4 As String
Get
Return m_CustomerField4
End Get
Set(value As String)
m_CustomerField4 = value
End Set
End Property
Public Property CustomerField5 As String
Get
Return m_CustomerField5
End Get
Set(value As String)
m_CustomerField5 = value
End Set
End Property
Public Property CreateDate As Date
Get
Return m_CreateDate
End Get
Set(value As Date)
m_CreateDate = value
End Set
End Property
Public Property CreateBy As String
Get
Return m_CreateBy
End Get
Set(value As String)
m_CreateBy = value
End Set
End Property
Public Property UpdateDate As Date
Get
Return m_UpdateDate
End Get
Set(value As Date)
m_UpdateDate = value
End Set
End Property
Public Property UpdateBy As String
Get
Return m_UpdateBy
End Get
Set(value As String)
m_UpdateBy = value
End Set
End Property
Public Property MarkDel As Nullable(Of Integer)
Get
Return m_MarkDel
End Get
Set(value As Nullable(Of Integer))
m_MarkDel = value
End Set
End Property
End Class
Last edited by Daniil; Jan 24, 2013 at 4:44 AM.
Reason: [CLOSED]