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

4 posts, 0 answers
  1. Austin
    Austin avatar
    13 posts
    Member since:
    Apr 2009

    Posted 29 Dec 2014 Link to this post

    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?
  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1980 posts

    Posted 01 Jan 2015 Link to this post

    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.

     
  3. Austin
    Austin avatar
    13 posts
    Member since:
    Apr 2009

    Posted 02 Jan 2015 in reply to Konstantin Dikov Link to this post


    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.
  4. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1980 posts

    Posted 07 Jan 2015 Link to this post

    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.

     
Back to Top