Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
133 views
I am using the "NeedDataSource" method to fill in a grid.  On the ItemDataBound I am setting the background colors for some values in a couple of column cells.  (Sub below)

This displays properly.  Dragging columns around works properly and the colors follow the cells.  However, when you do a grouping by dragging the column to the top of the grid the colors do not stay with the cells.

I have attached a before and after image...

Any ideas why this is moving?   I am setting the colors based on the FindByUniqueName identifier for the column.

Thanks,
Nathan


Protected Sub rgDispatch_ItemDataBound(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles rgDispatch.ItemDataBound
    '//Is it a GridDataItem
    If Not IsNothing(TryCast(e.Item, Telerik.Web.UI.GridDataItem)) Then
        'Get the instance of the right type
        Dim dataBoundItem As Telerik.Web.UI.GridDataItem = DirectCast(e.Item, Telerik.Web.UI.GridDataItem)
        'Set the desired color on the Status column based on the value
        Dim StatusColIndex As Integer = rgDispatch.Columns.FindByUniqueName("Status").OrderIndex
        Select Case dataBoundItem("Status").Text
            Case "Loading"
                dataBoundItem("Status").BackColor = System.Drawing.Color.Yellow
            Case "Loaded"
                dataBoundItem("Status").BackColor = System.Drawing.Color.DodgerBlue
            Case "Claimed"
                dataBoundItem("Status").BackColor = System.Drawing.Color.Orange
            Case "Started"
                dataBoundItem("Status").BackColor = System.Drawing.Color.FromArgb(19, 229, 19)  'Green color
            Case "Stopped"
                dataBoundItem("Status").BackColor = System.Drawing.Color.IndianRed
        End Select
        'Set the desired color on the Status column based on the value
        Dim MatReadyColIndex As Integer = rgDispatch.Columns.FindByUniqueName("MatReady").OrderIndex
        Select Case dataBoundItem("MatReady").Text
            Case "Yes"
                e.Item.Cells(MatReadyColIndex).BackColor = System.Drawing.Color.FromArgb(19, 229, 19)
            Case "No"
                e.Item.Cells(MatReadyColIndex).BackColor = System.Drawing.Color.IndianRed
        End Select
    End If
    If Not IsNothing(TryCast(e.Item, Telerik.Web.UI.GridPagerItem)) Then
        Dim pager As Telerik.Web.UI.GridPagerItem = DirectCast(e.Item, Telerik.Web.UI.GridPagerItem)
        Dim PagerLabel As Label = pager.FindControl("ChangePageSizeLabel")
        PagerLabel.Text = "Items per Page"
    End If
End Sub
Nathan
Top achievements
Rank 1
 answered on 06 Jun 2014
1 answer
247 views
I have a grid with a hyperlink to a network folder.  The location is constructed in a query based on some information that SHOULD be correct, but there are mistakes made by the end-users and the hyperlink on occasion will be correct.  

<telerik:GridTemplateColumn ColumnGroupName="DLB" UniqueName="Location"  Display="True" HeaderText="Files" >
    <ItemTemplate>
        <a href="<%# Eval("Location")%>" target="_blank">Open folder</a>
    </ItemTemplate>
</telerik:GridTemplateColumn>

For each row, I would like to somehow handle that hyperlink if the network folder does not exist.  Either there will be no link to click or popup a message that informs the user the network folder does not exist.

I figure I would likely use System.IO.Directory.Exists, but I am clueless as to how to implement that.  I have made some attempts and searched for a solution, but have not come up with anything that works for me.

Thank you!
Eyup
Telerik team
 answered on 06 Jun 2014
2 answers
78 views
I have noticed a new behavior in the editor in IE while upgrading to the latest version (2014.1.403). If you add certain styles (width, height, float, maybe others) to a block element (div, p, h1, etc), you can no longer select text in that element with the mouse. You can select the element itself, which is displayed with a border and handles, but not the content inside it. The keyboard works fine, but the mouse does not.

You can see this on your demo site. Go to the html tab, modify the opening p tag to include 'width:300px;' in the style, and go back to the design tab. Try to use the mouse to select some text.

The previous version I was using was 2013.2.717. No problem there.

The problem happens in all versions of IE. It seems to work properly in Firefox and Chrome.
Dan Ehrmann
Top achievements
Rank 1
 answered on 06 Jun 2014
6 answers
209 views
I have a radGrid with a FilterTemplate containing a radComboBox with CheckBoxes=true.
I want to preselect a number of items in the radComboBox but that doesn't seem to work inside the filtertemplate (while it works just fine for the radComboBox outside a grid)
The grid columns and template are created in server side code, the data is loaded via a pagemethod.
I minimized my code down to this:

gridtest.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using System.Web.Services;
 
namespace SMTX.Common.Web {
    public partial class gridtest : System.Web.UI.Page {
        protected void Page_Load(object sender, EventArgs e) {
            if (!Page.IsPostBack)
                initGrid();
        }
 
        public void initGrid() {
            Forms.BL.EntityClasses.ViewEntity objView = Forms.BL.MyCode.ViewFactory.fetch(18);
            RadGrid1.AllowFilteringByColumn = true;
 
            GridBoundColumn objCol = new GridBoundColumn {
                AllowFiltering = true,
                DataField = "Field1",
                HeaderText = "Field1",
                DataType = Type.GetType("System.String"),
                FilterTemplate = new FilterTemplateCombo()
            };
            RadGrid1.Columns.Add(objCol);
 
            objCol = new GridBoundColumn {
                AllowFiltering = false,
                DataField = "Field2",
                HeaderText = "Field2",
                DataType = Type.GetType("System.String")
            };
            RadGrid1.Columns.Add(objCol);
 
            ScriptManager.RegisterStartupScript(this, this.GetType(), "CallGetView", @"setTimeout(function() {radGrid_Init();}  , 1000);", true);
        }
 
        [WebMethod]
        public static List<dataContainer> GetData(List<GridFilterExpression> p_lstFilterExpressions) {
            List<dataContainer> lstData = getDataForGrid(p_lstFilterExpressions);
            return lstData;
        }
 
 
        public static List<dataContainer> getDataForGrid(List<GridFilterExpression> p_lstFilterExpressions) {
            List<dataContainer> lstData = dataContainer.getTestData();
            List<String> lstFilterValues = null;
            if (p_lstFilterExpressions.Count > 0)
                lstFilterValues = p_lstFilterExpressions[0].FieldValue.Split(new []{"||"}, StringSplitOptions.RemoveEmptyEntries).ToList();
             
            if (lstFilterValues == null)
                return lstData;
            else
                return lstData.Where(r => lstFilterValues.Contains(r.Field1)).ToList();
        }
 
    }
 
    public class dataContainer {
        public Object Field1 { get; set; }
        public Object Field2 { get; set; }
 
        public static List<dataContainer> getTestData() {
            List<dataContainer> lstToRetrun = new List<dataContainer>();
            lstToRetrun.Add(new dataContainer { Field1 = "Name1", Field2 = "Name1field2" });
            lstToRetrun.Add(new dataContainer { Field1 = "Name2", Field2 = "Name2field2" });
            return lstToRetrun;
        }
 
    }
    public class FilterTemplateCombo : ITemplate {
        object m_objDataSource;
 
        public FilterTemplateCombo() {
            m_objDataSource = new[] { "Name1", "Name2" };
        }
 
        public void InstantiateIn(Control objContainer) {
            RadComboBox objCombobox = new RadComboBox();
            objContainer.Controls.Add(objCombobox);
            objCombobox.DataSource = m_objDataSource;
            objCombobox.DataBind();
            objCombobox.OnClientItemChecked = "RadGrid_ComboBoxMultiFilterCommand";
            objCombobox.CheckBoxes = true;
            foreach (RadComboBoxItem objItem in objCombobox.Items)
                objItem.Checked = true;
        }
    }
}

gridtest.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="gridtest.aspx.cs" Inherits="SMTX.Common.Web.gridtest" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<html>
<body>
    <form id="form1" runat="server">
        <ajax:ToolkitScriptManager ID="MyToolkitScriptManager" runat="server" EnablePageMethods="true" />
        <telerik:RadGrid ID="RadGrid1" runat="server">
            <ClientSettings>
                <ClientEvents OnCommand="RadGrid_Command" />
            </ClientSettings>
        </telerik:RadGrid>
        <telerik:RadScriptBlock runat="server">
            <script type="text/javascript">
                function radGrid_Init() {
                    var tableView = $find("RadGrid1").get_masterTableView();
                    PageMethods.GetData(tableView.get_filterExpressions().toList(), RadGrid_Update);
                }
 
                function RadGrid_Command(sender, args) {
                    args.set_cancel(true);
                    var filterExpressions = sender.get_masterTableView().get_filterExpressions();
                    PageMethods.GetData(filterExpressions.toList(), RadGrid_Update);
                }
 
                function RadGrid_ComboBoxMultiFilterCommand(sender, args) {
                    var gridTableView = sender.get_parent().get_parent().get_masterTableView();
                    var arr_objItems = sender.get_checkedItems();
                    if (arr_objItems.length > 0) {
                        var strData = "";
                        for (var i = 0; i < arr_objItems.length; i++)
                            strData += "||" + arr_objItems[i].get_value();
                        gridTableView.filter("Field1", strData, Telerik.Web.UI.GridFilterFunction.Custom);
                    } else {
                        gridTableView.filter("Field1", "", Telerik.Web.UI.GridFilterFunction.NoFilter);
                    }
                }
 
                function RadGrid_Update(result) {
                    var tableView = $find("RadGrid1").get_masterTableView();
                    tableView.set_dataSource(result);
                    tableView.dataBind();
                }
            </script>
        </telerik:RadScriptBlock>
    </form>
</body>
</html>

I expect the radComboBox filter in Field1 to have it's 2 items checked, but that doesn't seem to be the case, although they were checked in the code.
Tim
Top achievements
Rank 1
 answered on 06 Jun 2014
6 answers
326 views
Hi,
In my radgrid when I no data the HTM table element of mastertableview don't take the whole width.
I try to force by CSS, javascript, but its size is overriden.

Could you give me an issue to force the width of the html table?
<NoRecordsTemplate>
    <div style="text-align: center; width: 100%;">
        <asp:Label Text="<%$Resources:RadGridLib,grid_client_master_no_records %>" ID="LabelNoDoc" runat="server" />
     </div>
</NoRecordsTemplate>

I also try to implemente the client events OnMasterTableViewCreating and OnMasterTableViewCreated, but no succes!

Bye.
Pavlina
Telerik team
 answered on 06 Jun 2014
0 answers
70 views
Hi,     

It is possible to decrease the opacity of the oval color so that some degree of
transparency is maintained even when there are many overlapping ovals? In the
center area of the screenshot below, it’s not possible to see distinct ovals
because the overlapping reaches full opacity very quickly.
suhashini
Top achievements
Rank 1
 asked on 06 Jun 2014
4 answers
108 views
When I group users into the month view thier names are not lining up properly with thier schedules and I also see allot of white space at the bottom of the screen.  I have the over flow behavior set to expand so users don't have to scroll within the scheduler.

<telerik:RadScheduler ID="RadScheduler1" runat="server" TimelineView-NumberOfSlots="5"
           Skin="Web20" EnableEmbeddedSkins="true" EnableEmbeddedBaseStylesheet="false"
           DataStartField="Start" DataEndField="End" DataSubjectField="Subject" DataKeyField="ID"
           EnableDescriptionField="true" GroupingDirection="Vertical" StartInsertingInAdvancedForm="True"
           AdvancedForm-Modal="False" OnAppointmentDelete="RadScheduler1_AppointmentDelete"
           OnAppointmentInsert="RadScheduler1_AppointmentInsert" OnAppointmentUpdate="RadScheduler1_AppointmentUpdate"
           OnFormCreating="RadScheduler1_FormCreating" OnFormCreated="RadScheduler1_FormCreated"
           OnAppointmentDataBound="RadScheduler1_AppointmentDataBound" OnDataBound="RadScheduler1_OnDataBound"
           OnNavigationComplete="RadScheduler1_NavigationComplete">
           <WeekView DayStartTime="06:00:00" DayEndTime="23:59:00" WorkDayStartTime="08:00:00"
               WorkDayEndTime="18:00:00" />
           <DayView DayStartTime="06:00:00" DayEndTime="23:59:00" WorkDayStartTime="08:00:00"
               WorkDayEndTime="18:00:00" />
           <MonthView VisibleAppointmentsPerDay="20" AdaptiveRowHeight="true" />
           <TimelineView SlotDuration="12:00:00" NumberOfSlots="10" TimeLabelSpan="2" ColumnHeaderDateFormat="dddd, MMMM d" />
           <ResourceStyles>
               <telerik:ResourceStyleMapping Type="Category" Text="Out of Office" ApplyCssClass="rsCategoryViolet" />
               <telerik:ResourceStyleMapping Type="Category" Text="After Hours" ApplyCssClass="rsCategoryRed" />
               <telerik:ResourceStyleMapping Type="Category" Text="Projects" ApplyCssClass="rsCategoryDarkGreen" />
               <telerik:ResourceStyleMapping Type="Category" Text="MACs" ApplyCssClass="rsCategoryGreen" />
               <telerik:ResourceStyleMapping Type="Category" Text="VNMS" ApplyCssClass="rsCategoryDarkBlue" />
               <telerik:ResourceStyleMapping Type="Category" Text="IPT/Engineering" ApplyCssClass="rsCategoryDarkRed" />
               <telerik:ResourceStyleMapping Type="Category" Text="Other" ApplyCssClass="rsCategoryOrange" />
               <telerik:ResourceStyleMapping Type="Category" Text="Remote Day" ApplyCssClass="rsCategoryYellow" />
               <telerik:ResourceStyleMapping Type="Category" Text="Region Coverage" ApplyCssClass="rsCategoryPink" />
           </ResourceStyles>
           <TimeSlotContextMenuSettings EnableDefault="true" />
           <AppointmentContextMenuSettings EnableDefault="true" />
       </telerik:RadScheduler>

protected override void OnPreRender(EventArgs e)
   {
       RadScheduler1.OverflowBehavior = OverflowBehavior.Expand;     
       base.OnPreRender(e);
   }
Hristo Valyavicharski
Telerik team
 answered on 06 Jun 2014
1 answer
110 views
the dropdownitem doesn't fade ,please see my picture. and below is my code.

<telerik:RadAutoCompleteBox ID="RadOilSystem" runat="server" AllowCustomEntry="True"
                                    DropDownHeight="400px" EmptyMessage="供油系统" InputType="Text" Skin="Forest" Width="100%">
                                    <WebServiceSettings Method="GetOilSystem" Path="aDefault.aspx" />
                                </telerik:RadAutoCompleteBox>

by the way setting AllowCustomEntry as True is very indispensible for my project,and the amount of my data is huge.
Hope you work happily!
Nencho
Telerik team
 answered on 06 Jun 2014
1 answer
348 views
I have following code snippet used for deleteing an selected item from ListBox. Following is the aspx code

<

 

telerik:RadListBox ID="rlbTag" runat="server" AutoPostBack="false" OnClientItemDoubleClicked="DeleteTags()" Width="250" EnableEmbeddedSkins="true" Height="80px" AllowAutomaticUpdates="true">

 

 

<ItemTemplate>

 

 

<table width="100%">

 

 

<tr>

 

 

<td align="left" ><asp:Label ID="lblTags" Text='<%# DataBinder.Eval(Container, "Text") %>' runat="server"></asp:Label></td>

 

 

<td align="right"><asp:ImageButton ImageUrl="~/images/Delete.gif" ID="btnDelete" Text="Delete" OnClientClick="return removeItem(event)" runat="server"/></td>

 

<%

--<asp:CheckBox id="cbUsers" runat="server" OnClick="checkboxReportClick(event);" Text='<%# DataBinder.Eval(Container, "Text") %>' />--%>

 

 

</tr>

 

 

</table>

 

 

</ItemTemplate>

 

 

</telerik:RadListBox>

 

 

</td>

Following is the implementation of removeItem method which will be triggered when user click on delete button in List Box item template

 

function

 

removeItem(e)

 

{

 

 

var RdListBox=$find("<%= rlbTag.ClientID %>");

 

 

 

var item = RdListBox.get_selectedItem();

 

RdListBox._selectedIndex = 0;

 

RdListBox.trackChanges();

RdListBox.get_items().remove(item);

RdListBox.commitChanges();

}

When  first time user clicks delete button to remove an item, selected item is gettiung null. Seconmd time it gets deleted from the list.
Can anyone help me to acheive remove functionality on cleint side?

Cliff
Top achievements
Rank 1
 answered on 06 Jun 2014
2 answers
73 views
We limit the selection of dates to the last 5 years, however by default the MonthYearFastNavigation shows the last 4 years, current year and the next 5 years. I was wondering if the user is able to change is so that dates that are not selectable won't show up either and that the user can see all the years that they can select from.

For the current year the user can see the years 2010 to 2019. But what we really want to show is 2009 to 2014 because those are the only years that the user can select dates from.
Lex
Top achievements
Rank 1
 answered on 06 Jun 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?