Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
732 views

Hi,

How can i find the last row of a rad grid and make the last row bold.

I Have a rad grid in which iam fetching the total from the database itself as in attached file. I do not want to add the footer and use aggregate function

Thanks in advance

Sushanth.B

Sushanth
Top achievements
Rank 1
 answered on 10 Nov 2016
11 answers
5.6K+ views
I am having issues when I already have a grid built in the aspx code and am adding columns dynamically from the server side end. The grid will show up with the proper header titles for each column, but as soon as I sort the headers disappear and when I go to the next page each cell is filled with 'System.Data.DataRowView'.

Is their anyway I can make the columns persist in the viewstate? Thanks in advanced.

aspx code:
<telerik:RadGrid ID="Grid1" runat="server" AllowFilteringByColumn="True" 
        AllowPaging="True" OnNeedDataSource="Grid1_NeedDataSource" AllowSorting="True" 
        GridLines="None" ShowGroupPanel="True" AutoGenerateColumns="true" PageSize="50" 
        Skin="Telerik" Visible="false" Width="98%"
        <MasterTableView AutoGenerateColumns="False" > 
           <Columns> 
                
            </Columns> 
        </MasterTableView> 
 
        <ClientSettings AllowColumnsReorder="True" AllowDragToGroup="True" ReorderColumnsOnClient="True"
        </ClientSettings> 
    </telerik:RadGrid> 

c# code:
NewColumn = new GridBoundColumn();
NewColumn.DataField = 
"COLUMN1";
NewColumn.UniqueName = 
"COLUMN1";
NewColumn.Visible = 
false;
Grid1.MasterTableView.Columns.Add(NewColumn); 
Marin
Telerik team
 answered on 09 Nov 2016
2 answers
107 views

I have a radgrid which is set to "GroupsDefaultExpanded=False" in the MasterTableView.   When a user expands one of the groups they can edit a row within that group which opens a radwindow so they can make changes.  Once they close the RadWindow and it returns to the original page, all of the groups are back to being collapsed, but the user wants the original group they were working on to remain expanded.  I am using vb.net and aspx pages.  How can I expand the original group when returning from the RadWindow?

RadWindow Code:

<script type="text/javascript">
    function RefreshData(oWnd, eventArgs) {
        <%=Page.ClientScript.GetPostBackEventReference(btnRefresh, "")%>
    }
</script>
<telerik:RadWindow ID="rwEditAttendance" Behaviors="Close" VisibleStatusbar="false" AutoSize="true" EnableViewState="false" runat="server" Modal="true" VisibleOnPageLoad="false" OnClientClose="RefreshData" />
<asp:Button runat="Server" ID="btnRefresh" style="display:none; width:0px; height:0px;" />

 

Table code:

<telerik:RadGrid ID="rgAttendanceManager" runat="server" AllowFilteringByColumn="False" AllowSorting="True" ShowGroupPanel="False" AutoGenerateColumns="False" BorderColor="Silver">
    <MasterTableView
        GridLines="None" Width="100%"
        NoDetailRecordsText="No data matching criteria specified"
        NoMasterRecordsText="No data matching criteria specified"
        EnableNoRecordsTemplate="true"
        DataKeyNames="EmployeeId,EventDate,TimecardCommentId,TCUniqueId,Modified"
        ShowGroupFooter="true" 
        GroupsDefaultExpanded="false"
        >
        <GroupByExpressions >
            <telerik:GridGroupByExpression >
                <SelectFields >
                    <telerik:GridGroupByField FieldName="EmployeeName" HeaderValueSeparator=""  HeaderText=" "  />
                </SelectFields>
                <GroupByFields >
                    <telerik:GridGroupByField FieldName="EmployeeName"  />
                </GroupByFields>
            </telerik:GridGroupByExpression>
        </GroupByExpressions>
 
        <Columns>
            <telerik:GridButtonColumn UniqueName="EditComment" Text="Edit Comment" ButtonType="LinkButton" CommandName="EditComment" />
            <telerik:GridDateTimeColumn DataField="EventDate" HeaderText ="Event Date"  SortExpression="EventDate" HeaderStyle-Wrap="false" DataFormatString="{0:d}"/>
             
            <telerik:GridDateTimeColumn DataField="HistoricalDate" HeaderText ="Historical Date"  SortExpression="HistoricalDate" HeaderStyle-Wrap="false" DataFormatString="{0:d}"/>
            <telerik:GridBoundColumn DataField="PaycodeName" HeaderText="Paycode Name" SortExpression="PaycodeName" ItemStyle-Wrap="false" />
            <telerik:GridBoundColumn DataField="CommentText" HeaderText="Comment Text" SortExpression="CommentText" ItemStyle-Wrap="false" />
            <telerik:GridNumericColumn DataField="CommentValue" HeaderText="Comment Value" HeaderStyle-Wrap="false" DataType="System.Decimal" AllowRounding="false" DecimalDigits="2" Aggregate="Sum" FooterText="Total Attendance Score: "/>
            <telerik:GridDateTimeColumn DataField="PunchIn" HeaderText ="Punch In"  SortExpression="PunchIn" HeaderStyle-Wrap="false" DataFormatString="{0:MM/dd/yyyy HH:mm}"/>
            <telerik:GridDateTimeColumn DataField="PunchOut" HeaderText ="Punch Out"  SortExpression="PunchOut" HeaderStyle-Wrap="false" DataFormatString="{0:MM/dd/yyyy HH:mm}"/>
            <telerik:GridCheckBoxColumn HeaderText="Modified" DataField="Modified" HeaderStyle-Wrap="false" />
        </Columns>
 
    </MasterTableView>
</telerik:RadGrid>

 

Patrick
Top achievements
Rank 1
 answered on 09 Nov 2016
1 answer
126 views

Hi There,

Is it possible to merge RadScheduler timeslots in Timeline view? I would like to display the number of appointments over two days. Currently, I managed to do this on one day only. Please see the following example code, I displayed number '7' on Mondays, what I need is to display number '7' over both Mondays and Tuesdays timeslots. Screenshot attached. Any suggestions will be greatly appreciated. Thank you!

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RadSchedulerTimeLineViewModification.aspx.cs" Inherits="RadSchedulerWebForm" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head id="Head1" runat="server">
    <title>Untitled Page</title>
    <style type="text/css">
        .rsMainHeader
        {
                width: auto !important;
                text-align:Left !important;
                padding-right:5px !important;
        }
        .MySlotGreen
       {
        color: #fff !important;  
        text-align:center !important;
        background-color:#69690a !important;
       }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <div style="width: 980px;">
            <telerik:RadScheduler runat="server" ID="RadScheduler1" SelectedView="TimelineView" ShowViewTabs="false" OnTimeSlotCreated="RadScheduler1_TimeSlotCreated"
            OnNavigationComplete="RadScheduler1_NavigationComplete" ColumnWidth="28" StartInsertingInAdvancedForm="true" AppointmentStyleMode="Default">
                <TimelineView SlotDuration="1" NumberOfSlots="30" GroupBy="User, Month" GroupingDirection="Vertical" ColumnHeaderDateFormat="MMM dd ddd" HeaderDateFormat="MMMM, yyyy"/> 
            </telerik:RadScheduler>
        </div>
    </form>
</body>
</html>

 

Code Behind:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;
using Telerik.Web.UI.Calendar;
using Telerik.Web.UI.Calendar.View;
 
public partial class RadSchedulerWebForm : System.Web.UI.Page
{
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        RadScheduler1.Provider = new XmlSchedulerProvider(Server.MapPath("~/App_Data/Appointments.xml"), true);
    }
 
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack & RadScheduler1.SelectedView == SchedulerViewType.TimelineView)
        {
            int year = RadScheduler1.SelectedDate.Year;
            int month = RadScheduler1.SelectedDate.Month;
            int numberOfDaysInCurrentMonth = DateTime.DaysInMonth(year, month);
            RadScheduler1.SelectedDate = new DateTime(year, month, 1);
            RadScheduler1.TimelineView.NumberOfSlots = numberOfDaysInCurrentMonth;
        }
    }
 
    protected void RadScheduler1_NavigationComplete(object sender, SchedulerNavigationCompleteEventArgs e)
    {
        if (RadScheduler1.SelectedView == SchedulerViewType.TimelineView)
        {
            int year = RadScheduler1.SelectedDate.Year;
            int month = RadScheduler1.SelectedDate.Month;
            int numberOfDaysInCurrentMonth = DateTime.DaysInMonth(year, month);
            RadScheduler1.SelectedDate = new DateTime(year, month, 1);
            RadScheduler1.TimelineView.NumberOfSlots = numberOfDaysInCurrentMonth;
        }
    }
 
    protected void RadScheduler1_TimeSlotCreated(object sender, Telerik.Web.UI.TimeSlotCreatedEventArgs e)
    {
        if (RadScheduler1.SelectedView == SchedulerViewType.TimelineView)
        {
            if (e.TimeSlot.Start.Date.DayOfWeek == DayOfWeek.Monday)
            {
                Label numberLabel = new Label();
                numberLabel.Text = "7";
                e.TimeSlot.CssClass = "MySlotGreen";
 
                e.TimeSlot.Control.Controls.Add(numberLabel);
            }
        }
    }
}

 

Ivan Danchev
Telerik team
 answered on 09 Nov 2016
3 answers
193 views
I have a webpage that has a RadGrid on it and when the page is opened I create an excel attachment using memory stream and send it in an email, then close the window. 

This all works great, I even don't show a prompt to close the window. 

I firmly beleive it has to do with this setting, OpenInNewWindow.  But when I do that
RadGrid Grid1 = (RadGrid)Page.Master.FindControl("Main").FindControl("RadGrid1");
Grid1.ExportSettings.OpenInNewWindow = true;


However, at the bottom of the page there is a dialog to Open, Save or Cancel. 
How can I disable this prompt? 

I have attached images from IE 9 and FireFox 11.

One trick I have seen and it works is to simply create a new html page and have a Redirect to that page at the end of the export that only has a window.close() in the JavaScript.
Daniel
Telerik team
 answered on 09 Nov 2016
5 answers
251 views

Hi,

I have a radtreeview control.  I bind this during the page load event.  I’d like to add some attributes to the nodes.

So far I have done this via the NodeDataBound event.  However what I really need to do is store some data from the original datatable in some attributes.

I guess to do this I need to create the radtreeview by looping through the datable and creating the nodes individually.  When I do this I can’t see a way to set the parent IDs?

Any suggestions?

Anton
Telerik team
 answered on 09 Nov 2016
3 answers
121 views
Please check in image  Grids are not Binding Correctly for the First Time when i search an ID . But after opening any FORM from these Binded Grids and came back to home then its looks fine . But why its not bind first time. ???Check in image Grid Blue Strips that's causing issue to perform task!..  Please Help me .
Quest
Top achievements
Rank 1
 answered on 09 Nov 2016
1 answer
93 views

Hi,

 

I have integrated radslider on one ouf our website, unfortunately it was not displying after deployment, it just shows 'Decrease' and 1 only. Please help

 

Dileep

Marin Bratanov
Telerik team
 answered on 09 Nov 2016
8 answers
1.6K+ views
Hi All ,
I need to customize the caption of the rad grid , but can find any way , to do it , the best thing i was Able to reach was customizing the header , is there any way to handle this matter and customize the caption or this is a limitation in the tool
Eyup
Telerik team
 answered on 09 Nov 2016
2 answers
122 views

I have a grid with two buttons on each row, open and remove. Using OnItemCommand click the button goes to the code fine, the remove button works fine but the open button always gets the id from the first row.

This is the code that creates the two buttons, the same except for the names and images.

                    GridButtonColumn gridButtonColumn = new GridButtonColumn();
               gridButtonColumn.ButtonType = GridButtonColumnType.ImageButton;
               gridButtonColumn.ImageUrl = "~/Images/OpenLinkIcon.png";
               gridButtonColumn.CommandName = "OpenLink";
               gridButtonColumn.UniqueName = "OpenLink";
               gridButtonColumn.Text = "Open Signup Template";
               gridButtonColumn.Display = true;
               gridButtonColumn.HeaderText = "";
               gridButtonColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
               gridButtonColumn.HeaderStyle.Width = Unit.Pixel(40);
               signupGrid.MasterTableView.Columns.Add(gridButtonColumn);

 

               gridButtonColumn = new GridButtonColumn();
               gridButtonColumn.ButtonType = GridButtonColumnType.ImageButton;
               gridButtonColumn.ImageUrl = "~/Images/DeleteIcon.png";
               gridButtonColumn.CommandName = "Delete";
               gridButtonColumn.UniqueName = "Delete";
               gridButtonColumn.Text = "Remove Signup Template";
               gridButtonColumn.Display = true;
               gridButtonColumn.HeaderText = "";
               gridButtonColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
               gridButtonColumn.HeaderStyle.Width = Unit.Pixel(40);
               signupGrid.MasterTableView.Columns.Add(gridButtonColumn);

 

This is the grid definition

<div id="GridDiv" runat="server" >
    <asp:panel runat="server" ID="Panel1"  CssClass="windowPercent" >
        <telerik:RadGrid runat="server" ID="SignupGrid" OnItemCommand="Grid_ItemCommand"></telerik:RadGrid>                 
    </asp:panel>
</div>

 

And  this the aspx.cs code for the Grid_ItemCommand.

protected void Grid_ItemCommand(object source, GridCommandEventArgs e)
{
    if (isPageRefresh || e == null || e.Item == null) {
        return;
    }
    
    GridDataItem item = (GridDataItem)e.Item;
    string strId = item[SignupListData.FIELD_ID].Text;
    switch (e.CommandName) {
        case "Delete":
            string name = item[SignupListData.FIELD_NAME].Text;
            lblConfirm.Text = "Are you sure you want to remove sigup template \"" + name + "\"?";
            RemoveSignup.Value = "Yes";
            RemoveId.Value = strId;
            break;
        case "OpenLink":
            this.Response.Redirect("/Signup/Design/" + strId);
            break;
    }
}

 

The   and name values for Delete is the proper one for the row, while the  for OpenLink is always the FIELD_ID from the first row,

Searching the forums  and examples I found several different ways of getting the field id value but none of them worked.

No idea how to fix this problem.

George

FYI: the form to post this to the forum has a buggy edit box.  If I backspace once its works but further ones will skip to the front of words removing spaces unexpectedly.  It was rather difficult to make this post.

George
Top achievements
Rank 2
 answered on 08 Nov 2016
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?