Greetings
I'm currently working on a project with RadGrid.
The website has one page and a RadGrid without any user settings.
By clicking buttons I change the type of the grid, its columns and its data.
Only when I have a Grid with two levels (e.g. DetailView), it's Impossible to replace it with other data that also has two levels.
For example, let's define:
A - One Level Grid (e.g. NO DetailView)
B - Grid with two levels (mastertabalView+DetailView)
A --> B (e.g. replace grid's data that has one level with data of two levels)
RESULT: REPLACEMENT SUCCESS
B --> A
RESULT: REPLACEMENT SUCCESS
B --> B
RESULT: REPLACEMENT FAIL
B --> A --> B
RESULT: REPLACEMENT FAILS
ASPX:
VB.NET:
Thanks,
Daniel
I'm currently working on a project with RadGrid.
The website has one page and a RadGrid without any user settings.
By clicking buttons I change the type of the grid, its columns and its data.
Only when I have a Grid with two levels (e.g. DetailView), it's Impossible to replace it with other data that also has two levels.
For example, let's define:
A - One Level Grid (e.g. NO DetailView)
B - Grid with two levels (mastertabalView+DetailView)
A --> B (e.g. replace grid's data that has one level with data of two levels)
RESULT: REPLACEMENT SUCCESS
B --> A
RESULT: REPLACEMENT SUCCESS
B --> B
RESULT: REPLACEMENT FAIL
B --> A --> B
RESULT: REPLACEMENT FAILS
ASPX:
<
telerik:RadGrid
ID
=
"RadGrid1"
Height
=
"100%"
runat
=
"server"
EnableHeaderContextMenu
=
"true"
>
<
ClientSettings
>
<
Scrolling
AllowScroll
=
"True"
></
Scrolling
>
</
ClientSettings
>
</
telerik:RadGrid
>
VB.NET:
001.
Protected
Sub
Page_Load(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
Me
.Load
002.
If
Not
IsPostBack
Then
003.
Session(
"st"
) =
Nothing
004.
Session(
"IsGridToBEShowen_flag"
) = 0
005.
End
If
006.
End
Sub
007.
008.
009.
Protected
Sub
Button1_Click(sender
As
Object
, e
As
EventArgs)
Handles
Button1.Click
010.
Session(
"Report_ID"
) = 1
011.
ReplaceReport
012.
End
Sub
013.
014.
015.
Protected
Sub
Button2_Click(sender
As
Object
, e
As
EventArgs)
Handles
Button2.Click
016.
Session(
"Report_ID"
) = 2
017.
ReplaceReport
018.
End
Sub
019.
020.
Protected
Sub
Button3_Click(sender
As
Object
, e
As
EventArgs)
Handles
Button3.Click
021.
Session(
"Report_ID"
) = 3
022.
ReplaceReport
023.
End
Sub
024.
025.
026.
027.
Private
Sub
ReplaceReport()
028.
029.
rep.ID = Session(
"Report_ID"
)
030.
031.
032.
Pre_Report()
033.
setGridProperties()
034.
035.
End_Set_Report()
036.
037.
End
Sub
038.
''''''''''''''''''''''''''''''''''''''''''
039.
040.
Private
Sub
Pre_Report()
041.
RadGrid1.Enabled =
True
042.
RadGrid1.Visible =
True
043.
Session(
"st"
) =
Nothing
044.
Session(
"isGridInit"
) =
True
045.
046.
Session(
"st"
) = rep.Data
'get specific DataSet into Session
047.
End
Sub
048.
049.
Private
Sub
End_Set_Report()
050.
051.
RadGrid1.DataSource =
CType
(Session(
"st"
), DataSet).Tables(0)
052.
053.
RadGrid1.DataBind()
054.
RadGrid1.Rebind()
055.
Session(
"IsGridToBEShowen_flag"
) = 1
056.
057.
End
Sub
058.
059.
''''''''''''''''''''
060.
''''''''''''''''''''''''''''''''''''''''''''
061.
Private
Sub
setGridProperties()
062.
063.
'set grid columns properties
064.
If
Session(
"RTL"
)
Then
065.
RadGrid1.MasterTableView.Dir = GridTableTextDirection.RTL
066.
Else
067.
RadGrid1.MasterTableView.Dir = GridTableTextDirection.LTR
068.
End
If
069.
070.
If
RadGrid1.MasterTableView.DetailTables.Count > 0
Then
071.
RadGrid1.MasterTableView.DetailTables(0).DataSource =
Nothing
072.
RadGrid1.MasterTableView.DetailTables(0).DataSource =
New
Object
() {}
073.
RadGrid1.MasterTableView.DetailTables(0).Rebind()
074.
075.
RadGrid1.MasterTableView.DetailTables.Remove(0)
076.
End
If
077.
078.
Dim
Number_Of_Tables
As
Integer
=
CType
(Session(
"st"
), DataSet).Tables.Count
079.
080.
If
Number_Of_Tables = 2
Then
081.
RadGrid1.DataSource =
Nothing
082.
RadGrid1.Rebind()
083.
'add details View
084.
Dim
detailsView1
As
GridTableView =
New
GridTableView()
085.
detailsView1.Name =
"Details"
086.
detailsView1.DataKeyNames =
New
String
() {
"Internal_ID"
}
087.
RadGrid1.MasterTableView.DetailTables.Add(detailsView1)
088.
RadGrid1.MasterTableView.DataKeyNames =
New
String
() {
"Internal_ID"
}
089.
RadGrid1.Rebind()
090.
091.
End
If
092.
093.
094.
RadGrid1.MasterTableView.TableLayout = GridTableLayout.Fixed
095.
RadGrid1.ClientSettings.Selecting.AllowRowSelect =
True
096.
RadGrid1.AllowSorting =
True
097.
RadGrid1.AllowPaging =
True
098.
RadGrid1.AllowMultiRowSelection =
True
099.
RadGrid1.ClientSettings.Scrolling.UseStaticHeaders =
True
100.
RadGrid1.ShowHeader =
True
101.
RadGrid1.AllowFilteringByColumn =
True
102.
RadGrid1.MasterTableView.AllowFilteringByColumn =
True
103.
RadGrid1.ClientSettings.AllowDragToGroup =
True
104.
RadGrid1.ShowGroupPanel =
True
105.
RadGrid1.MasterTableView.HeaderStyle.Width = Unit.Pixel(200)
106.
107.
RadGrid1.ClientSettings.Selecting.UseClientSelectColumnOnly =
True
108.
RadGrid1.ClientSettings.EnableRowHoverStyle =
True
109.
End
Sub
110.
111.
Private
Sub
FirstSortGrid(colum_name
As
String
)
112.
Dim
expression
As
GridSortExpression =
New
GridSortExpression()
113.
expression.FieldName = colum_name
114.
expression.SortOrder = GridSortOrder.Ascending
115.
RadGrid1.MasterTableView.SortExpressions.AddSortExpression(expression)
116.
Session(
"isGridInit"
) =
False
117.
End
Sub
118.
119.
Protected
Sub
RadGrid1_NeedDataSource(sender
As
Object
, e
As
GridNeedDataSourceEventArgs)
Handles
RadGrid1.NeedDataSource
120.
121.
Dim
fl
As
Integer
= Session(
"IsGridToBEShowen_flag"
)
122.
If
fl = 1
Then
123.
RadGrid1.DataSource =
CType
(Session(
"st"
), DataSet).Tables(0)
124.
125.
End
If
126.
127.
End
Sub
128.
129.
130.
131.
Private
Sub
RadGrid1_DetailTableDataBind(sender
As
Object
, e
As
GridDetailTableDataBindEventArgs)
Handles
RadGrid1.DetailTableDataBind
132.
Dim
dataItem
As
GridDataItem =
CType
(e.DetailTableView.ParentItem, GridDataItem)
133.
Select
Case
e.DetailTableView.Name
134.
Case
"Details"
135.
Dim
ConnectID
As
String
= dataItem.GetDataKeyValue(
"Internal_ID"
).ToString()
136.
CType
(Session(
"st"
), DataSet).Tables(1).DefaultView.RowFilter =
""
137.
CType
(Session(
"st"
), DataSet).Tables(1).DefaultView.RowFilter =
"Internal_ID = "
& ConnectID
138.
e.DetailTableView.DataSource =
CType
(Session(
"st"
), DataSet).Tables(1).DefaultView
139.
End
Select
140.
End
Sub
Thanks,
Daniel