or
Private Sub CreateDynamicControl() |
Dim i As Integer |
Dim iCellIndex As Integer |
Dim drFoundRecord As Data.DataRow() |
Try |
For i = 0 To gvDynamic.Rows.Count - 1 |
For iCellIndex = 1 To gvDynamic.Rows(i).Cells.Count - 1 |
If gvDynamic.Rows(i).Cells(iCellIndex).ID Is Nothing = False Then |
Dim cLabelItem As New Label |
Dim cTxtboxQty As New TextBox |
Dim cLabelWorkOrder As New Label |
Dim cTxtWorkOrder As New TextBox |
Dim cLiteraSpace1 As New LiteralControl |
Dim cLiteraSpaceBR As New LiteralControl |
Dim cLiteraSpace2 As New LiteralControl |
Dim cHtmlTable As New HtmlTable |
Dim radMenu As New Telerik.Web.UI.RadContextMenu |
Dim radMenuItem As New Telerik.Web.UI.RadMenuItem |
Dim radMenuItem2 As New Telerik.Web.UI.RadMenuItem |
Dim radMenuItem3 As New Telerik.Web.UI.RadMenuItem |
Dim target As New Telerik.Web.UI.ContextMenuControlTarget |
Dim button1 As New Button |
drFoundRecord = getRecordByKey(gvDynamic.Rows(i).Cells(iCellIndex).ID) |
If drFoundRecord.Length > 0 Then |
cHtmlTable = CreateDynamicHTMLTable() |
gvDynamic.Rows(i).Cells(iCellIndex).BackColor = Drawing.Color.BlanchedAlmond |
cLabelItem.ID = "lblItem" & gvDynamic.Rows(i).Cells(iCellIndex).ID |
cLabelItem.Text = drFoundRecord(0)("Planned_Item") |
radMenuItem.Text = "Edit" |
radMenuItem2.Text = "Delete" |
radMenuItem3.Text = "Firm" |
radMenu.Items.Add(radMenuItem) |
radMenu.Items.Add(radMenuItem2) |
radMenu.Items.Add(radMenuItem3) |
radMenuItem3.Attributes.Add("onclick", "return confirm('Are you sure you want to firm?');") |
radMenuItem2.Attributes.Add("onclick", "return confirm('Are you sure you want to delete?');") |
AddHandler radMenu.ItemClick, AddressOf cRadMenuItem1Click |
target.ControlID = cLabelItem.ID |
radMenu.Targets.Add(target) |
cHtmlTable.Rows(0).Cells(0).Controls.Add(radMenu) |
cHtmlTable.Rows(0).Cells(0).Controls.Add(cLabelItem) |
gvDynamic.Rows(i).Cells(iCellIndex).Controls.Add(cHtmlTable) |
End If |
End If |
Next |
Next |
Catch ex As Exception |
Throw ex |
End Try |
End Sub |
Protected Sub cRadMenuItem1Click(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadMenuEventArgs) |
Try |
Dim a As String |
a = "sfds" |
Catch ex As Exception |
Throw ex |
End Try |
End Sub |
Existing Grid With Only Master Table
-------------------------------------------
<
ST:STGrid
ID
=
"grdfilesParent"
runat
=
"server"
Width
=
"100%"
AllowPaging
=
"false"
GroupingEnabled
=
"true"
ShowGroupPanel
=
"false"
EnableHierarchyExpandAll
=
"true"
>
<
MasterTableView
HierarchyLoadMode
=
"Client"
>
<
Columns
>
<
tel:GridBoundColumn
UniqueName
=
"Name"
DataField
=
"Name"
HeaderText
=
"Category"
/>
<
tel:GridHyperLinkColumn
UniqueName
=
"Subject"
DataTextField
=
"Subject"
HeaderText
=
"Subject"
DataNavigateUrlFormatString
=
"attachments/display.aspx?id={0}"
DataNavigateUrlFields
=
"ID"
SortExpression
=
"Subject"
>
<
ItemStyle
CssClass
=
"gridhyperlink"
/>
</
tel:GridHyperLinkColumn
>
<
tel:GridHyperLinkColumn
UniqueName
=
"FileName"
DataTextField
=
"FileName"
HeaderText
=
"Attachment"
DataNavigateUrlFormatString
=
"{0}"
DataNavigateUrlFields
=
"AttachmentUrl"
SortExpression
=
"FileName"
Target
=
"_blank"
>
<
ItemStyle
CssClass
=
"gridhyperlink"
/>
</
tel:GridHyperLinkColumn
>
<
tel:GridDateTimeColumn
UniqueName
=
"CreatedDate"
DataField
=
"CreatedDate"
HeaderText
=
"Date"
/>
<
tel:GridBoundColumn
UniqueName
=
"CreatedBy"
DataField
=
"CreatedBy"
HeaderText
=
"Author"
/>
</
Columns
>
<
GroupByExpressions
>
<
tel:GridGroupByExpression
>
<
SelectFields
>
<
tel:GridGroupByField
FieldName
=
"Name"
FieldAlias
=
"Category"
/>
</
SelectFields
>
<
GroupByFields
>
<
tel:GridGroupByField
FieldName
=
"Name"
/>
</
GroupByFields
>
</
tel:GridGroupByExpression
>
</
GroupByExpressions
>
</
MasterTableView
>
<
ClientSettings
AllowExpandCollapse
=
"true"
>
</
ClientSettings
>
</
ST:STGrid
>
---------------------------------------------------
NeedDataSource Event of Above Grid:
--------------------------------------------
Private Sub grdfilesParent_NeedsDataSource(ByVal sender As Object, ByVal e As GridNeedDataSourceEventArgs) Handles grdAttachmentsParent.NeedDataSource
Dim types As fileTypeList = CurrentST.GetfileTypes()
Dim attachments = types.Aggregate(
New List(Of Object)(),
Function(acc As List(Of Object), type As STfileType)
Dim typefilements As STfilementList = Document.Getfilements(type.ID)
typefilements.Aggregate(
acc,
Function(acc2 As List(Of Object), filement As STfile)
Dim extension = file.Extension.ToLower()
Dim navigationUrl As String = String.Empty
If CurrentSTClient.av Then
navigationUrl = String.Format("files/view.aspx?id={0}&path={1}&aid={2}", file.Document.ID, file.FileName, file.ID)
ElseIf EnableCommentsWithfiles Then
navigationUrl = String.Format("reviews/displayReadOnlyOptional.aspx?id={0}&type=file&path={1}&aid={2}", file.Document.ID, file.FileName, file.ID)
Else
If (extension = "docx" _
OrElse extension = "doc" _
OrElse extension = "dotx" _
OrElse extension = "dot" _
OrElse extension = "rtf" _
OrElse extension = "xls" _
OrElse extension = "xlsx" _
) Then
navigationUrl = String.Format(
"reviews/displayreadonly.aspx?id={0}&type=file&path={1}",
file.ID,
file.FileName
)
Else
navigationUrl = file.VirtualPath
End If
End If
acc2.Add(New With {
Key .Name = type.Name,
.ID = file.ID,
.Subject = file.Subject,
.FileName = file.FileName,
.CreatedDate = String.Format("{0} {1}", file.CreatedDate.ToString(CurrentCulture.DateTimeFormat.ShortDatePattern, CurrentCulture), file.CreatedDate.ToString(CurrentCulture.DateTimeFormat.ShortTimePattern, CurrentCulture)),
.CreatedBy = file.CreatedBy,
.fileUrl = navigationUrl
})
Return acc2
End Function
)
Return acc
End Function
)
DirectCast(grdAttachmentsParent.Columns(1), GridHyperLinkColumn).DataNavigateUrlFormatString = String.Format("{0}cc/files/display.aspx?id={1}0{2}", Captions.VirtualRoot, Chr(123), Chr(125))
grdfilesParent.DataSource = files.ToArray()
End Sub
---------------------------------------------
I need to convert the above grid to the Grid like below with Master - Detail
-----------------------------------------------------------------------------------------
<
ST:STGrid
ID
=
"STGrdNotesMaster"
runat
=
"server"
TabIndex
=
"212"
AutoGenerateColumns
=
"false"
AllowSorting
=
"false"
AllowPaging
=
"false"
ClientSettings-AllowColumnsReorder
=
"false"
ClientSettings-AllowDragToGroup
=
"false"
ShowGroupPanel
=
"false"
EnableHierarchyExpandAll
=
"true"
MasterTableView-ExpandCollapseColumn-HeaderStyle-BackColor
=
"LightGray"
>
<
MasterTableView
DataKeyNames
=
"ID"
HierarchyDefaultExpanded
=
"false"
NoMasterRecordsText
=
""
NoDetailRecordsText
=
""
GroupLoadMode
=
"Client"
HierarchyLoadMode
=
"Client"
>
<
Columns
>
<
telerik:GridBoundColumn
HeaderText
=
"Category"
DataField
=
"Name"
UniqueName
=
"Category"
/>
<
telerik:GridTemplateColumn
UniqueName
=
"Reorder"
>
<
ItemTemplate
><
ST:STButton
ID
=
"btnReorder"
runat
=
"server"
CommandName
=
"reorder"
Text
=
"Reorder based on sort"
/></
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
<
DetailTables
>
<
telerik:GridTableView
Name
=
"Detail"
AllowSorting
=
"true"
AllowPaging
=
"false"
DataKeyNames
=
"ID"
NoMasterRecordsText
=
""
NoDetailRecordsText
=
""
EditMode
=
"InPlace"
>
<
Columns
>
<
telerik:GridHyperLinkColumn
UniqueName
=
"Subject"
HeaderText
=
"Subject"
DataNavigateUrlFormatString
=
"~/notedisplay.aspx?id={0}"
DataNavigateUrlFields
=
"ID"
DataTextField
=
"Subject"
SortExpression
=
"Subject"
ItemStyle-CssClass
=
"gridhyperlink"
HeaderStyle-Width
=
"500px"
/>
<
telerik:GridHyperLinkColumn
UniqueName
=
"file"
HeaderText
=
"file"
DataNavigateUrlFormatString
=
"javascript:void(window.open('imageviewer.aspx?a=3&b=file&c={0}', '_blank', 'left=0, top=0, width=785, height=585, titlebar=yes, location=no, status=no, toolbar=no, menubar=no, scrollbars=no, resizable=yes'));"
DataNavigateUrlFields
=
"ID"
DataTextField
=
"fileName"
SortExpression
=
"fileName"
ItemStyle-CssClass
=
"gridhyperlink"
/>
<
telerik:GridBoundColumn
UniqueName
=
"AddDate"
HeaderText
=
"Created"
DataField
=
"AddDate"
SortExpression
=
"AddDate"
ReadOnly
=
"true"
/>
<
telerik:GridEditCommandColumn
UniqueName
=
"EditColumn"
>
<
ItemStyle
CssClass
=
"gridhyperlink"
/>
</
telerik:GridEditCommandColumn
>
</
Columns
>
</
telerik:GridTableView
>
</
DetailTables
>
</
MasterTableView
>
<
ClientSettings
AllowExpandCollapse
=
"true"
>
</
ClientSettings
>
</
ST:STGrid
>
<
div
id
=
"ctl00_MainContent_TrafficSignalsGridUserControl_RadGridTrafficSignals_GridData"
class
=
"rgDataDiv"
style
=
"overflow-x: auto; overflow-y: scroll; width: 100%; height: 474px;"
>
<
div
id
=
"ctl00_MainContent_TrafficSignalsGridUserControl_RadGridTrafficSignals_ctl00_VirtualScroll"
style
=
"overflow-y: scroll; position: absolute; right: 0px; top: 0px; width: 18px; height: 458px;"
>
<
telerik:RadGrid
ID
=
"RadGridTrafficSignals"
runat
=
"server"
CssClass
=
"gridClass"
GridLines
=
"None"
AutoGenerateColumns
=
"False"
AllowSorting
=
"True"
EnableHeaderContextMenu
=
"True"
Width
=
"98%"
Height
=
"636px"
OnNeedDataSource
=
"RadGridTrafficSignals_NeedDataSource"
OnUpdateCommand
=
"RadGridTrafficSignals_OnUpdateCommand"
OnItemUpdated
=
"RadGridTrafficSignals_ItemUpdated"
OnDataBound
=
"RadGridTrafficSignals_DataBound"
OnItemCommand
=
"RadGridTrafficSignals_ItemCommand"
OnItemCreated
=
"RadGridTrafficSignals_OnItemCreated"
CellSpacing
=
"0"
AllowFilteringByColumn
=
"True"
ShowGroupPanel
=
"True"
ShowStatusBar
=
"False"
>
<
ClientSettings
AllowColumnsReorder
=
"True"
AllowDragToGroup
=
"True"
ReorderColumnsOnClient
=
"True"
>
<
ClientEvents
OnRowClick
=
"RowClick"
OnRowDblClick
=
"RowDblClick"
OnGridCreated
=
"GridCreated"
OnCommand
=
"GridCommand"
></
ClientEvents
>
<
Scrolling
AllowScroll
=
"True"
UseStaticHeaders
=
"True"
EnableVirtualScrollPaging
SaveScrollPosition
=
"True"
ScrollHeight
=
"458px"
></
Scrolling
>
<
Virtualization
EnableVirtualization
=
"true"
ItemsPerView
=
"100"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
/>
</
ClientSettings
>
...
</
telerik:RadGrid
>
<
telerik:RadGrid
ID
=
"RadGridDetectors"
runat
=
"server"
CssClass
=
"gridClass"
GridLines
=
"None"
AutoGenerateColumns
=
"False"
AllowSorting
=
"True"
EnableHeaderContextMenu
=
"True"
Width
=
"98%"
Height
=
"636px"
OnNeedDataSource
=
"RadGridDetectors_NeedDataSource"
OnUpdateCommand
=
"RadGridDetectors_OnUpdateCommand"
OnItemUpdated
=
"RadGridDetectors_ItemUpdated"
OnDataBound
=
"RadGridDetectors_DataBound"
OnItemCommand
=
"RadGridDetectors_ItemCommand"
OnItemCreated
=
"RadGridDetectors_OnItemCreated"
CellSpacing
=
"0"
AllowFilteringByColumn
=
"True"
ShowGroupPanel
=
"True"
ShowStatusBar
=
"False"
>
<
ClientSettings
AllowColumnsReorder
=
"True"
AllowDragToGroup
=
"True"
ReorderColumnsOnClient
=
"True"
>
<
ClientEvents
OnRowClick
=
"RowClick"
OnRowDblClick
=
"RowDblClick"
OnGridCreated
=
"GridCreated"
OnCommand
=
"GridCommand"
/>
<
Scrolling
AllowScroll
=
"True"
UseStaticHeaders
=
"True"
SaveScrollPosition
=
"True"
ScrollHeight
=
"458px"
/>
<
Virtualization
EnableVirtualization
=
"true"
ItemsPerView
=
"100"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
/>
</
ClientSettings
>