Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
385 views
Hi

I am trying to display a Telerik RadGrid in my project.
I have a problem with changing the column width.
The data source of my grid is a list of objects.
When I add filters to the grid, the columns' width is fixed and I cannot change it / resize it.

P.S. I want to solve this programmatically(in vb code) 

my vb code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
 setColumnsOnGrid(Of object)(lst, RadGrid1, ArrayNameFilds:={"column1", "column2", "column3 ", "etc."})
        End If
    End Sub
     
     
    Private Sub setColumnsOnGrid(Of T)(ByVal lst As List(Of T), ByVal grdName As RadGrid, ByVal ArrayNameFilds As Array)
        Dim nameFiled As String
        grdName.DataSource = lst
        grdName.AllowMultiRowSelection = True
        grdName.MasterTableView.AutoGenerateColumns = False
   
        Dim boundColumn As GridBoundColumn
 
        For i As Integer = 0 To ArrayNameFilds.Length - 1
            nameFiled = ArrayNameFilds(i).ToString()
            boundColumn = New GridBoundColumn()
            grdName.MasterTableView.Columns.Add(boundColumn)
            boundColumn.DataField = nameFiled
            boundColumn.HeaderText = nameFiled
         Next
    End Sub

my aspx:
<telerik:RadGrid ID="grd_test" runat="server" AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" CellSpacing="0" GridLines="None">
        <ClientSettings>
            <Scrolling AllowScroll="True" UseStaticHeaders="True" />
        </ClientSettings>
</telerik:RadGrid>
Nancy Moore
Top achievements
Rank 1
 answered on 01 Oct 2015
4 answers
138 views

Hello,

Below is some code to demonstrate my problem​ :

I use a grid with 3 pages, each containing ​only one ​row for simplicity.. The ​grid contains ​an hyperlink column  (another is visible here only for verification).

The first page is displayed by default and then we can observe ​a correct URL to the passage of the mouse over it.
Changing page call​s PageMethods to get data client side, and ​oddly the url is lost... However, verification column displays the correct URL.

 Thank you in advance for your help.

 

TestHyperLinkColumn.aspx :

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestHyperLinkColumn.aspx.cs" Inherits="Test.TestHyperLinkColumn" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
 
    <telerik:RadCodeBlock runat="server" ID="RadScriptBlock1">
 
        <script type="text/javascript">
            //<![CDATA[
 
            function RadGrid1_Command(sender, args) {
                args.set_cancel(true);
                $find("<%= RadAjaxLoadingPanel1.ClientID %>").show("<%= RadGrid1.ClientID %>");
 
 
                var currentPageIndex = sender.get_masterTableView().get_currentPageIndex();
                PageMethods.GetData(currentPageIndex + 1, updateGrid);
            }
 
            function updateGrid(result) {
                //Bind Grid
                var tableView = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
                var $ = $telerik.$;
                result = $.parseJSON(result);
                tableView.set_dataSource(result);
                tableView.dataBind();
                $find("<%= RadAjaxLoadingPanel1.ClientID %>").hide("<%= RadGrid1.ClientID %>");
            }
 
            //]]>
 
        </script>
 
    </telerik:RadCodeBlock>
 
    <telerik:RadScriptManager runat="server" EnableCdn="true" ID="RadScriptManager1" EnablePageMethods="true" />
 
     
    <telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel1">
    </telerik:RadAjaxLoadingPanel>
 
 
    <div>
       <telerik:RadGrid runat="server" ID="RadGrid1" AllowFilteringByColumn="true" FilterType="CheckList" AllowPaging="true" PagerStyle-AlwaysVisible="true" AllowSorting="true">
            <MasterTableView AutoGenerateColumns="False" PageSize="1" AllowFilteringByColumn="false">
                <Columns>
                    <telerik:GridHyperLinkColumn DataTextField="Link" HeaderText="Link" Target="_blank" DataType="System.String" DataNavigateUrlFields = "LinkURL">
                    </telerik:GridHyperLinkColumn>
                    <telerik:GridBoundColumn DataField="LinkURL" HeaderText="LinkURL" DataType="System.String" Visible="true">
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
            <PagerStyle AlwaysVisible="true" Mode="NumericPages" />
            <ClientSettings EnableRowHoverStyle="true">
                <ClientEvents OnCommand="RadGrid1_Command" />
            </ClientSettings>
        </telerik:RadGrid>
    </div>
     
    </div>
    </form>
</body>
</html>

 

TestHyperLinkColumn.aspx.cs :

using System;
using System.Collections.Generic;
using System.Data;
using System.Web.Services;
using System.Web.UI;
 
namespace Test
{
    public partial class TestHyperLinkColumn : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                RadScriptManager1.EnablePageMethods = true;
 
                DataTable data = GetDataTable(1, true);
                RadGrid1.MasterTableView.DataSource = data;
                RadGrid1.DataBind();
 
            }
        }
 
        private static string ConvertDataTabletoString(System.Data.DataTable dt)
        {
            System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>();
            Dictionary<string, object> row;
            foreach (System.Data.DataRow dr in dt.Rows)
            {
                row = new Dictionary<string, object>();
                foreach (System.Data.DataColumn col in dt.Columns)
                {
                    row.Add(col.ColumnName, dr[col]);
                }
                rows.Add(row);
            }
            return serializer.Serialize(rows);
        }
 
        private static DataTable GetDataTable(int pageIndex, bool first = false)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("Link", typeof(string));
            dt.Columns.Add("LinkURL", typeof(string));
            DataRow dr = dt.NewRow();
            dr[0] = string.Format("Link{0}", pageIndex);
            dr[1] = string.Format("http://www.link{0}.com", pageIndex);
            dt.Rows.Add(dr);
            pageIndex++;
            if (first)
            {   //Adds 2 rows only for pager because data not used (loaded from PageMethods)
                dr = dt.NewRow();
                dr[0] = "";
                dr[1] = "";
                dt.Rows.Add(dr);
                pageIndex++;
                dr = dt.NewRow();
                dr[0] = "";
                dr[1] = "";
                dt.Rows.Add(dr);
            }
            return dt;
        }
 
        [WebMethod]
        public static string GetData(int PageIndex)
        {
            DataTable dt = GetDataTable(PageIndex);
 
            string result = ConvertDataTabletoString(dt);
            return result;
        }
    }
}
 

luc bonenfant
Top achievements
Rank 1
 answered on 01 Oct 2015
8 answers
271 views
I have a RadGrid where an image in each row is added as the TargetControl to a RadToolTipManager to show a larger image when mousing over.  I have the HideEvent set to "LeaveTargetAndToolTip" but it only works when keeping the mouse over the tooltip.  If you leave the mouse over the target, it eventually goes away.  This same behavior actually happens on your own site's demo of this exact property.  What's the deal?
Fernando
Top achievements
Rank 2
 answered on 01 Oct 2015
5 answers
372 views
Hi,
i m creating multiple datePicker from Code behind and at run time itself i m adding the calendar control to same.But when I click on the datePicker it won't show me the calendar popup for the second instance that i have created.I have all these datePicker controls in dataList.

  RadDatePicker DatePicker = new RadDatePicker();
                        DatePicker.ViewStateMode = ViewStateMode.Enabled;
                        DatePicker.ID = "RadDatePicker_" + Field.AssessmentTemplateGroupId + "_" + Field.DBFieldName;
                        DatePicker.ClientIDMode = ClientIDMode.Static;
                        DatePicker.AutoPostBack = false;
                        
                        
                        DatePicker.Skin = "BariRC";
                        DatePicker.CssClass = "text";
                        DatePicker.EnableEmbeddedSkins = false;


                        RadCalendar calendar = new RadCalendar();
                        calendar.ID = "RadCalendar_" + Field.AssessmentTemplateGroupId + "_" + Field.DBFieldName;
                        calendar.UseColumnHeadersAsSelectors = false;
                        calendar.UseRowHeadersAsSelectors = false;
                        calendar.FastNavigationStep = 12;
                        calendar.EnableEmbeddedSkins = false;
                       
                        calendar.EnableMultiSelect = false;
                        
                        RadCalendarDay Day = new RadCalendarDay();
                        Day.Repeatable = RecurringEvents.Today;
                        calendar.SpecialDays.Add(Day);
                        DatePicker.Controls.Add(calendar);




                        RadDateInput dateInput = new RadDateInput();
                        dateInput.DateFormat = "MM/dd/yyyy";
                        dateInput.DisplayDateFormat = "MM/dd/yyyy";


                        DatePicker.Controls.Add(dateInput);


                        DatePicker.DatePopupButton.ImageUrl = "../../App_Themes/Bari_Default/images/calendar_ico.png";
                        DatePicker.DatePopupButton.HoverImageUrl = "../../App_Themes/Bari_Default/images/calendar_ico.png";
                        DateTime MinDate = new DateTime(1900, 01, 01);
                        DatePicker.MinDate = MinDate;

Thanks & regards
hiren
Viktor Tachev
Telerik team
 answered on 01 Oct 2015
3 answers
296 views

We have a page where you can download some files (via a link in a grid) and upload one file. When you first do a download of a file and then try to upload a file, the server side event FileUploaded is not triggered and only the click event of the related post trigger button is going off, but then the UploadedFiles property of the RadAsyncUpload doesn't have the uploaded file. When you click again on the button then the FileUploaded event is triggered.

The code to download the file is the following:

Dim stream As System.IO.MemoryStream = reportResult.ReportStream
response.Clear()
response.ClearHeaders()
Dim filter As IO.Stream = response.Filter
response.Filter = Nothing
response.ContentType = reportResult.Report.Type.MimeType
response.AddHeader("Content-Disposition", "attachment; filename=" & fileName)
If stream.Length > 0 Then stream.WriteTo(response.OutputStream)
response.End()

It seems that something in the download is making the RadAsyncUpload losing some triggers which are reset after the first postback.

Hristo Valyavicharski
Telerik team
 answered on 01 Oct 2015
2 answers
180 views

Hello,

 I want to ask user Are you sure you still want to submit?? after some checks which they had provided while submitting the forms, for simplicity you can think of 

 

protected void RadGrid1_InsertCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
    {

if((userControl.FindControl("TaskName") as RadTextBox).Text==SomeMethodaWhichReturnDataFromSQLSelect())

{

 // Here I want to Show user if this condition gets true 

RadWindowManager1.RadConfirm();

if( RadConfirm OK is Pressed)

{

// Insert statement

}

else     

}

}

 ​

Marin Bratanov
Telerik team
 answered on 01 Oct 2015
7 answers
87 views

Hi,

I use version 2015.01.401 of your controls.

In the RadScheduler_AppointmentCreated Event, I customize the subject of the Appointment with the code below:

 

AppointmentLinkButton.Text = String.Concat(e.Appointment.Subject, " - <i>(", DivisionName, " - ", OwnerName, ")</i>")

Dim emEventID As String = e.Appointment.Attributes("emEventID")

AppointmentLinkButton.PostBackUrl = EMLink.Url((Cbs.Data.SD.NavTreeObjectTypes.EventDetails).ToString(), emEventID)

Dim tooltipValueParam As String = String.Concat(emEventID, PIPE_DELIMETER, SessUserCultureCode, PIPE_DELIMETER, SessUserID)

Dim jscript As String = "javascript:showProjectToolTip(this,'" & tooltipValueParam & "');"

Dim jscriptClearTimer As String = "javascript:clearTimeout(timer1);"

ImagesLiteralControl.Text = String.Format(APPTSUBJECTIMAGESTRING_CONST, "../../img/icons/event-bricks_small.png", jscript, jscriptClearTimer) ​

e.Appointment.BackColor = System.Drawing.ColorTranslator.FromHtml(e.Appointment.Attributes("DivisionChartHexColor"))

AppointmentLinkButton.ForeColor = GetIdealTextColor(e.Appointment.BackColor)

 

You can also see that I have code in that event that sets the background color of the appointments, based on user configurable colors stored in our database (they are not in CSS files).  I've attached the SchedulerInWebApp.png file to show you what it looks like in the web app.  The image that is there, uses a radtooltip manager to call a web service to display more information.  And the actual text is a link to the item in our system.

My problem is that when I do an export to PDF, the image isn't found and the subject contains no text.  I've attached the SchedulerPDFOutput.png to show that.

Question:  How can I get the Export to NOT try to embed the image, and have it just display the custom text that I am creating?

Thanks in Advance,

Brent

Plamen
Telerik team
 answered on 01 Oct 2015
1 answer
126 views
Im wondering..
I can't see any documentation on Lightweight rendermode of the splitter control.
Is that not supported og os the splitter allready quite modern and lightwaight by design?
Marin Bratanov
Telerik team
 answered on 01 Oct 2015
14 answers
316 views
Hello guys,

i'm having problem with gridtempletecolumn, when i add boundcolums the data shown properly but when i use templetecolum it does not show the data, can any one solve my problem.

check images below for more clearification
Mohamed
Top achievements
Rank 1
 answered on 01 Oct 2015
1 answer
83 views

hi,

I think this is quite an extreme test but this is what happen:

+ Pass endDate to RadScheduler with the value of 30-12-9999 ( or 31-12-9999) the maximum date that a date control can support.

Then RadScheduler run into a runtime error, below is the stack trace :

System.DateTime.AddTicks(Int64 value)
System.DateTime.Add(TimeSpan value)
Telerik.Web.UI.Scheduler.Views.Timeline.Model.DataBind(AppointmentCollection appointments)
Telerik.Web.UI.Scheduler.Views.Timeline.GroupedByResource.Model.DataBind(AppointmentCollection appointments)
Telerik.Web.UI.RadScheduler.CreateContent()
Telerik.Web.UI.RadScheduler.CreateChildControls(Boolean bindFromDataSource)
System.Web.UI.Control.EnsureChildControls()
Telerik.Web.UI.RadScheduler.LoadPostData(String postDataKey, NameValueCollection postCollection)

 

The reason is : Radscheduler try to AddTick to a MaxDate value. (Currently the Timelineview.TimeSlotDuration  = 1 day - the defaulted value)

My question : Why it failed even if I pass in 30-12-9999 . Because the MaxDate should be 31-12-9999

I am thinking of only allow date <= 30-12-9999  ( but now it failed with this value 30-12-9999)

And restrict it to 29-12-9999 does not look right.

 Any idea is much appreciated.

 regards,

 Lam.

 

 

Ivan Danchev
Telerik team
 answered on 01 Oct 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Top achievements
Rank 1
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ivory
Top achievements
Rank 1
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
YF
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Top achievements
Rank 1
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ivory
Top achievements
Rank 1
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
YF
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?