Rad Grid Updating Issue

6 posts, 1 answers
  1. James
    James avatar
    4 posts
    Member since:
    Sep 2015

    Posted 15 Sep 2015 Link to this post

    Hi All,

    Let me start off by saying I am a noob when it comes to using asp.net and telerik. With that being said I am having an issue updating the headers of the rad grid. When I run the application in Visual Studio the headers are correct, however when I build the solution and run the application on the internet the headers still reflect the old text (before the text change).The  application in question was built by someone else using asp.net, c#, javascript, ajax, etc. I am pretty sure the version of telerik used originally is much older than the version I am using today which is the most current version as of 9/15/15 . I should also mention there are two versions of the application one being used now by employees and one I am working on a development sever. The header text that should be changed should be both the Approval and Status text.

    I added two images below to show you what the app looks like in visual studio vs what it looks when run on the internet.

     Code ASCX:

    <telerik:RadGrid ID="HistoryCard" runat="server" OnNeedDataSource="HistoryCard_NeedDataSource" OnItemDataBound="HistoryCard_ItemDataBound">
     
            <MasterTableView AutoGenerateColumns="false">
                        <Columns>
                            <telerik:GridBoundColumn HeaderText="Due Date" DataField="due_date" DataFormatString="{0:MM/dd/yyyy}" />
                            <telerik:GridBoundColumn HeaderText="Inspection Dates" DataField="inspection_date" DataFormatString="{0:MM/dd/yyyy}" />
                <telerik:GridTemplateColumn HeaderText="Status" UniqueName="Status">
                                <ItemTemplate>
                                    <%# Common.EquipmentStatus.GetLabel(Eval("current_use")) %>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn HeaderText="Approval" UniqueName="Approval">
                                <ItemTemplate>
                                    <%# Common.HistoryStatus.GetLabel(Eval("status")) %>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn HeaderText="Adjusted">
                                <ItemTemplate>
                                    <%# GiTools.DataTypes.Bool.Format(Eval("adjusted"), "Yes", "No") %>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridBoundColumn HeaderText="Remarks:" DataField="remarks" ItemStyle-CssClass="history_card_links" />
                            <telerik:GridTemplateColumn HeaderText="Inspector">
                                <ItemTemplate>
                                    <%# GiTools.Mail.MailHelper.MakeMailToLink(null, null, Eval("email"), Eval("name")) %>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                 
     
     
                        </Columns>
                    </MasterTableView>
     
           
                </telerik:RadGrid>

  2. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 18 Sep 2015 Link to this post

    Hello,

    Based on the provided description it is rather difficult to determine what exactly is the issue you are facing. From the screenshots provided i noticed that the Approval column is hidden for some reason on the web version. I believe that you might have some programmatic logic for setting this column to be invisible. Can you please let me know what the exact  you are expecting is and also provide the full markup of the RadGrid as well as the related code behind so that we can further revision it and advise you for possible solution for your issue.

    behaviorRegards,
    Maria Ilieva
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. James
    James avatar
    4 posts
    Member since:
    Sep 2015

    Posted 18 Sep 2015 in reply to Maria Ilieva Link to this post

    Hello Maria,

    Thank you for responding to my inquiry. I am sorry if I didn’t explain myself clearly. So here is the original code before the change. What I would like to do is change (“CUS” to “Status”) and (“Status” change to “Approval”).

    Original Code:

      

    <MasterTableView AutoGenerateColumns="false">
                        <Columns>
                            <telerik:GridBoundColumn HeaderText="Due Date" DataField="due_date" DataFormatString="{0:MM/dd/yyyy}" />
                            <telerik:GridBoundColumn HeaderText="Inspection Dates" DataField="inspection_date" DataFormatString="{0:MM/dd/yyyy}" />
                                                    <telerik:GridTemplateColumn HeaderText="CUS" >
                                <ItemTemplate>
                                    <%# Common.EquipmentStatus.GetLabel(Eval("current_use")) %>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn HeaderText="Status" >
                                <ItemTemplate>
                                    <%# Common.HistoryStatus.GetLabel(Eval("status")) %>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn HeaderText="Adjusted">
                                <ItemTemplate>
                                    <%# GiTools.DataTypes.Bool.Format(Eval("adjusted"), "Yes", "No") %>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridBoundColumn HeaderText="Remarks:" DataField="remarks" ItemStyle-CssClass="history_card_links" />
                            <telerik:GridTemplateColumn HeaderText="Inspector">
                                <ItemTemplate>
                                    <%# GiTools.Mail.MailHelper.MakeMailToLink(null, null, Eval("email"), Eval("name")) %>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                        </Columns>
                    </MasterTableView>

     

    Code Behind:

    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Web.UI;
     
    public partial class UserControls_EquipmentView : System.Web.UI.UserControl
    {
        protected void HistoryCard_PreRender(object sender, EventArgs e)
        {
            foreach (GridColumn col in HistoryCard.MasterTableView.RenderColumns)
            {
                if (col.UniqueName == "TemplateColumn2")
                {
                    col.HeaderText = "MyName";
                }
     
                HistoryCard.Rebind();
            }
        
     
        public int? EditId { set; get; }
        public bool PrintMode { set; get; }
     
        protected void Page_Load(object sender, EventArgs e)
        {
            DataClassesDataContext dc = new DataClassesDataContext();
            equipment equipment = dc.equipments.FirstOrDefault(_r => _r.equipment_id == EditId);
     
            if (equipment == null)
            {
                Response.Redirect("~/Default.aspx");
            }
            else
            {
                if (!PrintMode && ((MasterPageBase)this.Page.Master).UserLocationsIds.Contains(equipment.group_id))
                {
                    Server.Transfer("EquipmentEdit.aspx?ID=" + EditId.ToString());
                    Response.End();
                    return;
                }
                else
                {
                    if (!PrintMode)
                    {
                        ((MasterPageBase)this.Page.Master).SetTitle("View Equipment Information - TMS # " + equipment.tms_num);
                    }
                    else
                    {
                        Page.Title = "Equipment Information - TMS # " + equipment.tms_num;
                    }
     
                    Tms_Num.Text = equipment.tms_num;
                    Type.Text = Common.EquipmentType.GetLabel(equipment.type);
                    Due_Date.Text = equipment.due_date.HasValue ? equipment.due_date.Value.ToString("MM/dd/yyyy") : "N/A";
                    Assigned_To.Text = equipment.assigned_to;
                    Issued_To.Text = equipment.issued_to;
                    Department.Text = equipment.department;
                    Location.Text = Common.Groups.GetLabel(equipment.group_id);
                    Manufacturer.Text = equipment.manufacturer;
                    Model_Num.Text = equipment.model_num;
                    Serial_Num.Text = equipment.serial_num;
                    Description.Text = equipment.description;
                    Characteristics.Text = equipment.characteristics;
                    Calibration_Procedure.Text = equipment.calibration_procedure;
                    Calibration_Standard.Text = equipment.calibration_standard;
                    Calibration_Interval.Text = equipment.calibration_interval;
                    if (equipment.type == (int)Common.EquipmentTypeEnum.Electronic)
                    {
                        Required_Accuracy_Label.Visible = Required_Accuracy.Visible = false;
                    }
                    else
                    {
                        Required_Accuracy.Text = equipment.required_accuracy;
                    }
                    Date_Received.Text = equipment.date_received.HasValue ? equipment.date_received.Value.ToString("MM/dd/yyyy") : string.Empty;
                    Status.Text = Common.EquipmentStatus.GetLabel(equipment.status);
     
                    if (equipment.equipment_files.Count > 0)
                    {
                        Attached_Files.DataSource = equipment.equipment_files.OrderBy(_r => _r.file_name);
                        Attached_Files.DataBind();
                    }
                }
            }
        }
     
        protected void HistoryCard_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            string queryString = string.Format(
            "SELECT h.date_submitted AS date, h.history_id, o.otr_id, NULL AS request_id, h.history_id AS sort_id, h.inspector AS name, h.inspector_email AS email, h.due_date, h.inspection_date, h.current_use, h.status, h.adjusted, h.remarks " +
            "FROM history AS h  " +
            "LEFT JOIN otr o ON o.history_id = h.history_id WHERE h.equipment_id = {0} " +
            "UNION " +
            "SELECT o.date_submitted AS date, h.history_id, o.otr_id, NULL AS request_id, o.otr_id AS sort_id, o.submitted_by AS name, o.submitted_by_email AS email, h.due_date, h.inspection_date, h.current_use, h.status, h.adjusted, h.remarks " +
            "FROM otr AS o LEFT JOIN history h ON o.history_id = h.history_id " +
            "WHERE o.equipment_id = {0} AND h.history_id IS NULL " +
            "UNION " +
            "SELECT er.date_submitted AS date, NULL AS history_id, NULL AS otr_id, er.request_id, er.request_id AS sort_id, er.submitted_by AS name, er.submitted_by_email AS email, NULL as due_date, NULL AS inspection_date, NULL AS current_use, NULL AS status, NULL AS adjusted, er.submitter_comments AS remarks " +
            "FROM extension_requests er " +
            "WHERE er.equipment_id = {0} " +
            "ORDER BY date DESC, sort_id DESC"
                , EditId);
            HistoryCard.DataSource = GiTools.Database.MsSql.SqlToDataTable(Common.ConnectionString, queryString);
        }
     
     
        protected void HistoryCard_ItemDataBound(object sender, GridItemEventArgs e)
        {  
     
            if (e.Item is GridDataItem)
            {
                string otr_id = DataBinder.Eval(e.Item.DataItem, "otr_id", string.Empty) as string;
                string history_id = DataBinder.Eval(e.Item.DataItem, "history_id", string.Empty) as string;
                string request_id = DataBinder.Eval(e.Item.DataItem, "request_id", string.Empty) as string;
                string remarks = DataBinder.Eval(e.Item.DataItem, "remarks", string.Empty) as string;
                string comments = string.Empty;
     
                if (!string.IsNullOrEmpty(otr_id))
                {
                    comments = Common.GetOtrViewLink(otr_id);
                }
                else if (!string.IsNullOrEmpty(request_id))
                {
                    comments = Common.GetExtensionRequestViewLink(request_id);
                }
     
                if (!string.IsNullOrEmpty(remarks))
                {
                    comments += " " + remarks;
                }
                else if (!string.IsNullOrEmpty(otr_id))
                {
                    comments = Common.GetOtrViewLink(otr_id) + " OTR w/o History Card";
                }
     
                e.Item.Cells[7].Text = comments;
            }
        }
     
    }
     

  5. Answer
    Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 23 Sep 2015 Link to this post

    Hi James,

    I'm still not completely sure what you mean by change (“CUS” to “Status”) and (“Status” change to “Approval”). Are you trying to reorder columns or setting some order index from the grid loading. Please explain the required result a bit more so that we can advise you further.

    Regards,
    Maria Ilieva
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. James
    James avatar
    4 posts
    Member since:
    Sep 2015

    Posted 23 Sep 2015 in reply to Maria Ilieva Link to this post

    Hello,

     No, I am not trying to reorder columns. I am simply trying to change the headerText of the column.

    James

  7. James
    James avatar
    4 posts
    Member since:
    Sep 2015

    Posted 24 Sep 2015 in reply to Maria Ilieva Link to this post

    Hi Maria,

     Thank You for all your help. I was able to pinpoint what was happening. 

     

    James

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017