This is a migrated thread and some comments may be shown as answers.

Batch edit; How to have a column with static text?

7 Answers 214 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Austin
Top achievements
Rank 1
Austin asked on 29 Dec 2014, 08:37 PM
I have a RadGrid which I'm supplying with a dataSource from Entity Framework.  Let's say there are 6 columns.  The first column is a 'FromDate', the second column I just want to have the static text "To" inside it, both in row display and in row add/edit, and the third column I have 'ToDate'.

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

Sort by
0
Konstantin Dikov
Telerik team
answered on 01 Jan 2015, 12:34 PM
Hello Austin,

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.

 
0
Austin
Top achievements
Rank 1
answered on 02 Jan 2015, 06:29 PM

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.
0
Konstantin Dikov
Telerik team
answered on 07 Jan 2015, 09:24 AM
Hello Austin,

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.

 
0
Austin
Top achievements
Rank 1
answered on 11 May 2017, 10:36 PM

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'"/>

0
Austin
Top achievements
Rank 1
answered on 11 May 2017, 10:37 PM

Going over my old posts.  This is what I used:

 

<telerik:GridCalculatedColumn HeaderText="To" HeaderStyle-Width="40px" HeaderStyle-HorizontalAlign="Center" Expression="'To'"/>

0
Austin
Top achievements
Rank 1
answered on 11 May 2017, 10:37 PM
Going over my old posts.  This is what I used:

<telerik:GridCalculatedColumn HeaderText="To" HeaderStyle-Width="40px" HeaderStyle-HorizontalAlign="Center" Expression="'To'"/>

0
Austin
Top achievements
Rank 1
answered on 11 May 2017, 10:37 PM
Going over my old posts.  This is what I used:

<telerik:GridCalculatedColumn HeaderText="To" HeaderStyle-Width="40px" HeaderStyle-HorizontalAlign="Center" Expression="'To'"/>

Tags
Grid
Asked by
Austin
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Austin
Top achievements
Rank 1
Share this question
or