Hi all,
I have some problems regarding No Wrap for Grid Cells and I couldn't find any solution for this in the forum or the tutorials.
I have a grid with a HeaderTemplate and an ItemTemplate and I want to prevent the wrapping for cells content (see attached picture). The grid is filled dynamically, so where and how do I have to insert the NoWrap?
Any help would be appreciated!
Here's my code:
I have some problems regarding No Wrap for Grid Cells and I couldn't find any solution for this in the forum or the tutorials.
I have a grid with a HeaderTemplate and an ItemTemplate and I want to prevent the wrapping for cells content (see attached picture). The grid is filled dynamically, so where and how do I have to insert the NoWrap?
Any help would be appreciated!
Here's my code:
Private
Sub
Create_Templates(
ByRef
grdTemplate
As
RadGrid,
ByVal
sRegGruppe
As
String
,
ByVal
nIdGruppe
As
Integer
,
ByVal
bNurPlatzkosten
As
Boolean
)
Dim
templateColumn
As
New
GridTemplateColumn()
templateColumn.HeaderText = sRegGruppe
templateColumn.HeaderTemplate =
New
MyTemplateHeader(sRegGruppe, nIdGruppe, bNurPlatzkosten)
templateColumn.ItemTemplate =
New
MyTemplate(nIdGruppe, bNurPlatzkosten)
grdTemplate.MasterTableView.Columns.Add(templateColumn)
End
Sub
Private
Class
MyTemplateHeader
Implements
ITemplate
Private
sColHeader
As
String
Private
nIdCol
As
Integer
Private
bNurPK
As
Boolean
Sub
New
(
ByVal
sColHeaderBez
As
String
,
ByVal
nIdGruppe
As
Integer
,
ByVal
bNurPlatzk
As
Boolean
)
sColHeader = sColHeaderBez
nIdCol = nIdGruppe
bNurPK = bNurPlatzk
End
Sub
Sub
InstantiateIn(
ByVal
container
As
System.Web.UI.Control)
Implements
ITemplate.InstantiateIn
Dim
TmpTable
As
New
Table()
Dim
TmpRow1
As
New
TableRow()
Dim
TmpRow2
As
New
TableRow()
Dim
cReg
As
New
TableCell()
Dim
cES
As
New
TableCell()
Dim
cDS
As
New
TableCell()
Dim
cBU
As
New
TableCell()
TmpTable.Width = Unit.Percentage(100)
cReg.Width = Unit.Percentage(100)
cReg.Text = sColHeader
cReg.HorizontalAlign = HorizontalAlign.Center
TmpRow1.Cells.Add(cReg)
cES.Text =
"ES"
cES.Width = Unit.Percentage(100)
cES.HorizontalAlign = HorizontalAlign.Center
TmpRow2.Cells.Add(cES)
If
bNurPK =
False
Then
cReg.ColumnSpan = 3
cDS.Text =
"DS"
cBU.Text =
"Buchbar"
cDS.Width = Unit.Percentage(45)
cBU.Width = Unit.Percentage(10)
cDS.HorizontalAlign = HorizontalAlign.Center
cBU.HorizontalAlign = HorizontalAlign.Center
TmpRow2.Cells.Add(cDS)
TmpRow2.Cells.Add(cBU)
End
If
TmpTable.Rows.Add(TmpRow1)
TmpTable.Rows.Add(TmpRow2)
container.Controls.Add(TmpTable)
End
Sub
End
Class
Private
Class
MyTemplate
Implements
ITemplate
Protected
lControlEZ
As
LiteralControl
Protected
lControlDZ
As
LiteralControl
Protected
lControlBu
As
LiteralControl
Private
nIdCol
As
Integer
Private
bNurPK
As
Boolean
Private
nfZahl
As
Integer
Sub
New
(
ByVal
nIdGruppe
As
Integer
,
ByVal
bNurPlatzk
As
Boolean
)
nIdCol = nIdGruppe
bNurPK = bNurPlatzk
End
Sub
Sub
InstantiateIn(
ByVal
container
As
System.Web.UI.Control)
Implements
ITemplate.InstantiateIn
Dim
table
As
New
Table()
Dim
row1
As
New
TableRow()
Dim
cell11
As
New
TableCell()
Dim
cell12
As
New
TableCell()
Dim
cell21
As
New
TableCell()
table.CellPadding = 0
table.CellSpacing = 0
table.BorderStyle = BorderStyle.None
table.Width = Unit.Percentage(100)
lControlEZ =
New
LiteralControl()
lControlEZ.ID =
"ES"
& nIdCol
AddHandler
lControlEZ.DataBinding,
AddressOf
lControlEZ_DataBinding
cell11.Width = Unit.Percentage(100)
cell11.BorderStyle = BorderStyle.None
row1.Cells.Add(cell11)
If
bNurPK =
False
Then
lControlDZ =
New
LiteralControl()
lControlDZ.ID =
"DS"
& nIdCol
AddHandler
lControlDZ.DataBinding,
AddressOf
lControlDZ_DataBinding
lControlBu =
New
LiteralControl()
lControlBu.ID =
"Buchbar"
& nIdCol
AddHandler
lControlBu.DataBinding,
AddressOf
lControlBu_DataBinding
cell11.Width = Unit.Percentage(45)
cell12.Width = Unit.Percentage(45)
cell21.Width = Unit.Percentage(10)
cell11.BorderStyle = BorderStyle.None
cell12.BorderStyle = BorderStyle.None
cell21.BorderStyle = BorderStyle.None
row1.Cells.Add(cell12)
row1.Cells.Add(cell21)
End
If
table.Rows.Add(row1)
cell11.Controls.Add(lControlEZ)
If
bNurPK =
False
Then
cell12.Controls.Add(lControlDZ)
cell21.Controls.Add(lControlBu)
End
If
container.Controls.Add(table)
End
Sub
Private
Sub
boolValue_DataBinding(
ByVal
sender
As
Object
,
ByVal
e
As
EventArgs)
Dim
cBox
As
CheckBox =
DirectCast
(sender, CheckBox)
Dim
container
As
GridDataItem =
DirectCast
(cBox.NamingContainer, GridDataItem)
cBox.Checked = (
DirectCast
(container.DataItem, DataRowView))(
"Buchbar"
& nIdCol).ToString()
End
Sub
Public
Sub
lControlEZ_DataBinding(
ByVal
sender
As
Object
,
ByVal
e
As
EventArgs)
Dim
l
As
LiteralControl =
DirectCast
(sender, LiteralControl)
Dim
container
As
GridDataItem =
DirectCast
(l.NamingContainer, GridDataItem)
l.Text =
String
.Format(
"{0:C}"
, (
DirectCast
(container.DataItem, DataRowView))(
"ES"
& nIdCol))
End
Sub
Public
Sub
lControlDZ_DataBinding(
ByVal
sender
As
Object
,
ByVal
e
As
EventArgs)
Dim
l
As
LiteralControl =
DirectCast
(sender, LiteralControl)
Dim
container
As
GridDataItem =
DirectCast
(l.NamingContainer, GridDataItem)
l.Text =
String
.Format(
"{0:C}"
, (
DirectCast
(container.DataItem, DataRowView))(
"DS"
& nIdCol))
End
Sub
Public
Sub
lControlBu_DataBinding(
ByVal
sender
As
Object
,
ByVal
e
As
EventArgs)
Dim
l
As
LiteralControl =
DirectCast
(sender, LiteralControl)
Dim
container
As
GridDataItem =
DirectCast
(l.NamingContainer, GridDataItem)
If
(
DirectCast
(container.DataItem, DataRowView))(
"Buchbar"
& nIdCol).ToString() =
"1"
Then
l.Text =
"√"
Else
l.Text =
"-"
End
If
End
Sub
End
Class