I have everything working just fine, except that 'static text' of "To"... I don't know what format to put in the markup page. I have tried several combinations.
<
telerik:GridTemplateColumn
HeaderText
=
"To"
HeaderStyle-Width
=
"40px"
HeaderStyle-HorizontalAlign
=
"Center"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblTo"
runat
=
"server"
Text
=
"To"
Width
=
"100%"
/>
</
ItemTemplate
>
<
EditItemTemplate
>
<
asp:Label
ID
=
"lblTo"
runat
=
"server"
Text
=
"To"
Width
=
"100%"
/>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
Above I tried putting a label in each GridTemplateColumn, but this doesn't work out. Do I need to use a different type of column?
7 Answers, 1 is accepted
I have tester your GridTemplateColumn and it is working correctly on my end. Following is a simple example that I have tested locally:
<
telerik:RadGrid
runat
=
"server"
ID
=
"RadGrid1"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
Width
=
"450px"
>
<
MasterTableView
EditMode
=
"Batch"
AutoGenerateColumns
=
"false"
>
<
BatchEditingSettings
EditType
=
"Row"
/>
<
Columns
>
<
telerik:GridDateTimeColumn
DataField
=
"FromDate"
HeaderText
=
"From Date"
></
telerik:GridDateTimeColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"To"
HeaderStyle-Width
=
"40px"
HeaderStyle-HorizontalAlign
=
"Center"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblTo"
runat
=
"server"
Text
=
"To"
Width
=
"100%"
/>
</
ItemTemplate
>
<
EditItemTemplate
>
<
asp:Label
ID
=
"lblTo"
runat
=
"server"
Text
=
"To"
Width
=
"100%"
/>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridDateTimeColumn
DataField
=
"ToDate"
HeaderText
=
"To Date"
></
telerik:GridDateTimeColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
And the code-behind:
protected
void
RadGrid1_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
DataTable table =
new
DataTable();
table.Columns.Add(
"ID"
,
typeof
(
int
));
table.Columns.Add(
"FromDate"
,
typeof
(DateTime));
table.Columns.Add(
"ToDate"
,
typeof
(DateTime));
for
(
int
i = 0; i < 5; i++)
{
table.Rows.Add(i, DateTime.Now.AddDays(i), DateTime.Now.AddDays(i + 5));
}
(sender
as
RadGrid).DataSource = table;
}
Can you please test the above and see what differs in your actual implementation.
I am looking forward to your reply.
Regards,
Konstantin Dikov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Honestly, when I copy and paste that code into my test solution using controls 2013.3.1114.40 this is what I get:
To
1/7/2015 12:02:13 PM
1/3/2015 12:02:13 PM
To
1/8/2015 12:02:13 PM
1/4/2015 12:02:13 PM
To
1/9/2015 12:02:13 PM
1/5/2015 12:02:13 PM
To
1/10/2015 12:02:13 PM
1/6/2015 12:02:13 PM
To
1/11/2015 12:02:13 PM
No records to display.
I have tested the example from my previous post with version 2013.3 1114 and everything is rendering as expected. Attached you could find a screenshot with the result.
If the same example does not render correctly on your end, can you please record a short video demonstrating the problems. You can also open a regular support ticket and attach a sample, runnable project, so we can test it locally.
I am looking forward to your reply.
Best Regards,
Konstantin Dikov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Going over my old posts: I wound up using the below solution as it doesn't show an 'edit' control when the user is enter UI values, it simply adds in the 'To' text in the column of every row.
<telerik:GridCalculatedColumn HeaderText="To" HeaderStyle-Width="40px" HeaderStyle-HorizontalAlign="Center" Expression="'To'"/>
Going over my old posts. This is what I used:
<telerik:GridCalculatedColumn HeaderText="To" HeaderStyle-Width="40px" HeaderStyle-HorizontalAlign="Center" Expression="'To'"/>
<telerik:GridCalculatedColumn HeaderText="To" HeaderStyle-Width="40px" HeaderStyle-HorizontalAlign="Center" Expression="'To'"/>
<telerik:GridCalculatedColumn HeaderText="To" HeaderStyle-Width="40px" HeaderStyle-HorizontalAlign="Center" Expression="'To'"/>