Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
97 views
The grid looks great when I first opened the page.
But after any operation such as sever-side selection , sort. It looks there are something wrong with it.



Princy
Top achievements
Rank 2
 answered on 16 Apr 2014
1 answer
173 views
hi,

i just wanted to ask you if there is a way to use the radeditor with arabic language. Also, i would like to ask you if there is a way to export a arabic content of a radeditor to PDF

thank,
ali al-baqshi
KNPC
Ianko
Telerik team
 answered on 16 Apr 2014
3 answers
186 views
I developed a control to sort and order modules in a document. This is done in a telerik treeview control.

This works fine in Sharepoint 2010. Now I have the requirement to deploy this to Sharepoint 2013, but the site collection is running in "2010 compatibility mode". What happens now is, the page is loaded and I see all the controls. But after the second, sometimes the third click on any button in the treeview (does not affect other standard buttons on the page), the control disappears when trying to rebind. The code behind is executed, but in the browser console (same behaviour in IE/FF) I see errors like
IE: window._WebForm_InitCallback() -> (SCRIPT438: Object doesn't support this
property or method )

FF: init.js -> too much recursion

The control is still "available" in the page source, but seems not to be able to draw itself again. I added screenshots to show the control before and after. The browser shows a long list of maybe 100 entries "WebForm_Initcallback, init.js. This is probably the "too much recursion shown in the javascript debugger.


I started with a 2011 Telerik.Web.UI control version, since this is an old project, but on seeing the error, updated to the latest version 2014.1.225.35. This solution works fine in Sharepoint 2010, and Sharepoint 2013 (site collection in non-compat mode)

I can't pinpoint the error, since it's thrown in minified sharepoint javascript files. Has anyone experienced this problem before?



ASPX
<telerik:RadFormDecorator ID="FormDecorator1" runat="server" DecoratedControls="all"
       Skin="Telerik"></telerik:RadFormDecorator>
   <telerik:RadAjaxPanel ID="RadAjaxPanel1" LoadingPanelID="RadAjaxLoadingPanel1" runat="server">
       <asp:Button ID="btnExpandAll" runat="server" onclick="btnExpandAll_Click" Text="<%$Resources:MSH_DocumentCreatorUI,ReportGenerator_ExpandButtonText%>"/>
       <telerik:RadTreeList runat="server" ID="RadTreeList1" DataKeyNames="ID" ParentDataKeyNames="ParentChapter"
           OnNeedDataSource="RadTreeList1_NeedDataSource" OnUpdateCommand="RadTreeList1_UpdateCommand"
           OnInsertCommand="RadTreeList1_InsertCommand" OnItemCommand="RadTreeList1_ItemCommand"
           OnItemDataBound="RadTreeList1_ItemDataBound" AutoGenerateColumns="false" EditMode="InPlace"
           OnDataBinding="RadTreeList1_DataBinding" GridLines="None" NoRecordsText="<%$Resources:MSH_DocumentCreatorUI,ChapterEditor_NoRecordsText%>">
           <Columns>
               <docCreator:CustomTreeListEditCommandColumn UniqueName="EditCommandColumn" ButtonType="ImageButton"
                   InsertText="<%$Resources:MSH_DocumentCreatorUI,ChapterEditor_SaveButtonText%>"
                   AddRecordText="<%$Resources:MSH_DocumentCreatorUI,ChapterEditor_AddButtonText%>"
                   HeaderStyle-Width="200px" DeleteButtonImageUrl="/_layouts/Images/DocumentCreator/delete.png"
                   DeleteButtonID="DeleteButton" DeleteButtonCommand="Delete" DeleteButtonText="<%$Resources:MSH_DocumentCreatorUI,ChapterEditor_DeleteButtonText%>"
                   UpButtonImageUrl="/_layouts/Images/DocumentCreator/up.png" UpButtonID="UpButton"
                   UpButtonCommand="Up" UpButtonText="<%$Resources:MSH_DocumentCreatorUI,ChapterEditor_MoveUpButtonText%>"
                   DownButtonImageUrl="/_layouts/Images/DocumentCreator/down.png" DownButtonID="DownButton"
                   DownButtonCommand="Down" DownButtonText="<%$Resources:MSH_DocumentCreatorUI,ChapterEditor_MoveDownButtonText%>"
                   LeftButtonImageUrl="/_layouts/Images/DocumentCreator/left.png" LeftButtonID="LeftButton"
                   LeftButtonCommand="Left" LeftButtonText="<%$Resources:MSH_DocumentCreatorUI,ChapterEditor_MoveLeftButtonText%>"
                   RightButtonImageUrl="/_layouts/Images/DocumentCreator/right.png" RightButtonID="RightButton"
                   RightButtonCommand="Right" RightButtonText="<%$Resources:MSH_DocumentCreatorUI,ChapterEditor_MoveRightButtonText%>">
               </docCreator:CustomTreeListEditCommandColumn>
               <telerik:TreeListTemplateColumn HeaderText="<%$Resources:MSH_DocumentCreatorUI,ChapterEditor_ChapterNumberColumnHeaderText%>"
                   ItemStyle-Width="70px" HeaderStyle-Width="70px" UniqueName="ChapterNumber">
                   <ItemTemplate>
                       <asp:Label ID="lblChapterNumber" runat="server"></asp:Label>
                   </ItemTemplate>
                   <EditItemTemplate>
                       <asp:Label ID="lblChapterNumber" runat="server"></asp:Label>
                   </EditItemTemplate>
               </telerik:TreeListTemplateColumn>
               <telerik:TreeListBoundColumn DataField="Title" HeaderText="<%$Resources:MSH_DocumentCreatorUI,ChapterEditor_TextColumnHeaderText%>"
                   UniqueName="Title">
               </telerik:TreeListBoundColumn>
               <telerik:TreeListTemplateColumn HeaderText="<%$Resources:MSH_DocumentCreatorUI,ChapterEditor_LinkColumnHeaderText%>"
                   UniqueName="Link">
                   <ItemTemplate>
                       <asp:Repeater ID="textModulesRepeater" runat="server">
                           <ItemTemplate>
                               <asp:HyperLink ID="lblLink" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Title") %>' NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "Url") %>'></asp:HyperLink>
                               <br />
                           </ItemTemplate>
                       </asp:Repeater>
                   </ItemTemplate>
                   <EditItemTemplate>
                       <div style="overflow: auto; width: 100%; max-height: 200px; position: relative;">
                           <asp:CheckBoxList ID="textModulesList" runat="server" CssClass="textModuleCheckboxList" />
                       </div>
                   </EditItemTemplate>
               </telerik:TreeListTemplateColumn>
               <telerik:TreeListTemplateColumn HeaderText="<%$Resources:MSH_DocumentCreatorUI,ChapterEditor_StatusColumnHeaderText%>"
                   UniqueName="Status">
                   <ItemTemplate>
                       <asp:Image ID="Image1" ImageUrl='<%# this.GetImageUrlForColumnStatus(DataBinder.Eval(Container.DataItem, "Status")) %>'
                           runat="server" /><asp:Label ID="lblStatus" Style="vertical-align: top; margin-left: 5px"
                               runat="server" Text='<%# this.GetLabelForColumnStatus(DataBinder.Eval(Container.DataItem, "Status")) %>'></asp:Label>
                   </ItemTemplate>
                   <EditItemTemplate>
                       <asp:DropDownList runat="server" ID="ddlStatus">
                           <asp:ListItem Text="<%$Resources:MSH_DocumentCreatorUI,StatusEnum_Green_Description%>"
                               Value="Green"></asp:ListItem>
                           <asp:ListItem Text="<%$Resources:MSH_DocumentCreatorUI,StatusEnum_Yellow_Description%>"
                               Value="Yellow"></asp:ListItem>
                           <asp:ListItem Text="<%$Resources:MSH_DocumentCreatorUI,StatusEnum_Red_Description%>"
                               Value="Red" Selected="True"></asp:ListItem>
                       </asp:DropDownList>
                   </EditItemTemplate>
               </telerik:TreeListTemplateColumn>
           </Columns>
       </telerik:RadTreeList>
   </telerik:RadAjaxPanel>
   <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />


Code Behind

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Collections;
using Microsoft.SharePoint;
using System.Collections.Generic;
using Microsoft.SharePoint.Linq;
using Telerik.Web.UI;
using System.Data;
using System.Linq;
using MSH.DocumentCreator.DataAccess;
using MSH.DocumentCreator;
using MSH.DocumentCreator.DocumentGeneration;
 
namespace MSH.DocumentCreator.ChapterEditor
{
    public partial class ChapterEditorUserControl : UserControl
    {
        ReportStructure _docStructure;
        DataTable _textModules;
        IEnumerable<int> selectedTextModules;
 
        ReportStructure DocumentStructure
        {
            get
            {
                if (_docStructure == null)
                    _docStructure = new ReportStructure();
                return _docStructure;
            }
        }
 
        private Dictionary<int, double?> itemOrderMaxValuesByParent = new Dictionary<int, double?>();
        private Dictionary<int, double?> itemOrderMinValuesByParent = new Dictionary<int, double?>();
        private Dictionary<int, string> itemChapterNumber = new Dictionary<int, string>();
        private Dictionary<int, int> chapterParentIds = new Dictionary<int, int>();
 
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            selectedTextModules = new List<int>();
            foreach (ChaptersItem item in DocumentStructure.Chapters)
            {
                selectedTextModules = selectedTextModules.Union(item.LinkId.Select(l => l.Value));
            }
        }
 
        protected void btnExpandAll_Click(object sender, EventArgs e)
        {
            RadTreeList1.ExpandAllItems();
        }
 
        #region Commands
        protected void RadTreeList1_InsertCommand(object sender, TreeListCommandEventArgs e)
        {
            this.DocumentStructure.Chapters.InsertOnSubmit(GetChapter(e.Item as TreeListDataInsertItem));
            this.DocumentStructure.SaveChapters();
        }
 
        protected void RadTreeList1_UpdateCommand(object sender, TreeListCommandEventArgs e)
        {
            GetChapter(e.Item as TreeListDataItem);
            this.DocumentStructure.SaveChapters();
            ReBind();
        }
 
        public void RadTreeList1_ItemCommand(object sender, TreeListCommandEventArgs e)
        {
            if (e.CommandName == "InitInsert" || e.CommandName == "PerformInsert" || e.CommandName == "Edit" || e.CommandName == "Cancel")
                return;
 
            ChaptersItem currentItem = GetChapter(e.Item as TreeListDataItem);
            int id = (e.Item as TreeListDataItem).GetId("ID");
            switch (e.CommandName)
            {
                case "Left":
                    DocumentStructure.MoveLeft(currentItem);
                    break;
                case "Right":
                    DocumentStructure.MoveRight(currentItem);
                    break;
                case "Up":
                    DocumentStructure.MoveUp(currentItem);
                    break;
                case "Down":
                    DocumentStructure.MoveDown(currentItem);
                    break;
                case "Delete":
                    DocumentStructure.DeleteRecursively(currentItem);
                    DocumentStructure.SaveChapters();
                    break;
                default:
                    break;
            }
            RadTreeList1.Rebind();
        }
        #endregion
 
        #region Binding
        protected void RadTreeList1_NeedDataSource(object sender, TreeListNeedDataSourceEventArgs e)
        {
            RadTreeList1.DataSource = DocumentStructure.Chapters.OrderBy(ch => ch.ItemOrder).ToList<ChaptersItem>();
        }
 
        protected void RadTreeList1_DataBinding(object sender, EventArgs e)
        {
            ReportParts tm = new ReportParts();
            _textModules = tm.GetByContentType("Text-Module", "Text Module");
        }
 
        public void RadTreeList1_ItemDataBound(object sender, TreeListItemDataBoundEventArgs e)
        {
            if (e.Item is TreeListHeaderItem)
            {
                (e.Item.Controls[0].Controls[0] as Button).ToolTip = MSH.DocumentCreator.Modules.UIResources.MSH_DocumentCreatorUI.ChapterEditor_AddChapterText;
            }
            switch (e.Item.ItemType)
            {
                case TreeListItemType.EditItem:
                    DropDownList ddlStatus = e.Item.FindControl("ddlStatus") as DropDownList;
                    ChaptersItem spItem = null;
                    if (e.Item is TreeListDataItem)
                        spItem = this.DocumentStructure.GetChapter((e.Item as TreeListDataItem).GetId("ID"));
                    if (spItem != null && spItem.Status.HasValue)
                        ddlStatus.SelectedValue = spItem.Status.Value.ToString();
                    CheckBoxList chkListTextModules = e.Item.FindControl("textModulesList") as CheckBoxList;
                    if (spItem != null)
                    {
                        var item = DocumentStructure.GetChapter(spItem.ID.Value);
                        PopulateHierarchyDictionaries(item);
                    }
                    if (chkListTextModules != null)
                    {
                        chkListTextModules.DataSource = GetUnusedOrOwnTextModules(spItem == null ? null : spItem.LinkId);
                        chkListTextModules.DataTextField = "Title";
                        chkListTextModules.DataValueField = "ID";
                        chkListTextModules.DataBind();
                    }
 
                    if (spItem != null && spItem.LinkId != null && spItem.LinkId.Count != 0)
                    {
                        foreach (int? docId in spItem.LinkId)
                        {
                            foreach (ListItem item in chkListTextModules.Items)
                                if (docId.Value.ToString() == item.Value)
                                {
                                    item.Selected = true;
                                }
                        }
                    }
 
                    if (spItem != null)
                    {
                        Label lblChNumber = e.Item.FindControl("lblChapterNumber") as Label;
                        lblChNumber.Text = itemChapterNumber[spItem.ID.Value];
                    }
 
                    break;
                case TreeListItemType.Item:
                case TreeListItemType.AlternatingItem:
 
                    int id = (e.Item as TreeListDataItem).GetId("ID");
 
                    var currentItem = DocumentStructure.GetChapter(id);
                    var parentChapterId = currentItem.ParentChapter ?? -1;
                    PopulateHierarchyDictionaries(currentItem);
 
                    if (!itemOrderMinValuesByParent[parentChapterId].HasValue || itemOrderMinValuesByParent[parentChapterId] >= currentItem.ItemOrder)
                    {
                        ImageButton upButton = e.Item.FindControl("UpButton") as ImageButton;
                        upButton.Enabled = false;
                        upButton.ImageUrl = "/_layouts/Images/DocumentCreator/up_gray.png";
                    }
                    if (!itemOrderMaxValuesByParent[parentChapterId].HasValue || itemOrderMaxValuesByParent[parentChapterId] <= currentItem.ItemOrder)
                    {
                        ImageButton downButton = e.Item.FindControl("DownButton") as ImageButton;
                        downButton.Enabled = false;
                        downButton.ImageUrl = "/_layouts/Images/DocumentCreator/down_gray.png";
                    }
                    if (!currentItem.ParentChapter.HasValue)
                    {
                        ImageButton leftButton = e.Item.FindControl("LeftButton") as ImageButton;
                        leftButton.Enabled = false;
                        leftButton.ImageUrl = "/_layouts/Images/DocumentCreator/left_gray.png";
                    }
                    if (!DocumentStructure.Chapters.Any(ch => ch.ParentChapter == currentItem.ParentChapter && ch.ItemOrder < currentItem.ItemOrder))
                    {
                        ImageButton rightButton = e.Item.FindControl("RightButton") as ImageButton;
                        rightButton.Enabled = false;
                        rightButton.ImageUrl = "/_layouts/Images/DocumentCreator/right_gray.png";
                    }
 
                    Repeater textModulesRepeater = e.Item.FindControl("textModulesRepeater") as Repeater;
                    if (textModulesRepeater != null)
                    {
                        textModulesRepeater.DataSource = GetTextModulesWithCountry(currentItem.LinkId);
                        textModulesRepeater.DataBind();
                    }
 
                    Label lblNumber = e.Item.FindControl("lblChapterNumber") as Label;
                    lblNumber.Text = itemChapterNumber[currentItem.ID.Value];
 
                    break;
                default:
                    break;
            }
        }
 
        protected void checkBoxList_DataBound(object sender, EventArgs args)
        {
            CheckBoxList checkBoxes = sender as CheckBoxList;
            foreach (ListItem item in checkBoxes.Items)
            {
                item.Attributes.Add("Style", "padding: 0px !important;");
            }
        }
 
        private void ReBind()
        {
            RadTreeList1.DataSource = this.DocumentStructure.Chapters.OrderBy(ch => ch.ItemOrder);
            RadTreeList1.DataBind();
        }
        #endregion
 
        #region Helpers
 
        protected string GetImageUrlForColumnStatus(object status)
        {
            switch ((Status)status)
            {
                case Status.Red:
                    return "/_layouts/Images/DocumentCreator/red_ball.png";
                case Status.Green:
                    return "/_layouts/Images/DocumentCreator/green_ball.png";
                case Status.Yellow:
                    return "/_layouts/Images/DocumentCreator/yellow_ball.png";
                default:
                    return string.Empty;
            }
        }
 
        protected string GetLabelForColumnStatus(object status)
        {
            return Helpers.GetDescription((Status)status);
        }
 
        private ChaptersItem GetChapter(TreeListDataItem item)
        {
            return GetChapterValues(item, item.ParentItem);
 
        }
 
        private ChaptersItem GetChapter(TreeListDataInsertItem item)
        {
            return GetChapterValues(item, item.ParentItem);
        }
 
        private ChaptersItem GetChapterValues(TreeListEditableItem item, TreeListDataItem parentItem)
        {
            int? id = null;
            ChaptersItem chapter = null;
            if (item is TreeListDataItem)
            {
                id = (item as TreeListDataItem).GetId("ID");
                chapter = DocumentStructure.GetChapter(id.Value);
            }
            else
                chapter = new ChaptersItem();
 
            chapter.ParentChapter = GetParentId(parentItem);
 
            Hashtable values = item.GetValues();
            DropDownList ddlStatus = item.FindControl("ddlStatus") as DropDownList;
            if (ddlStatus != null)
            {
                Status statusValue = Status.None;
                if (ddlStatus.SelectedValue != null)
                    statusValue = (Status)Enum.Parse(typeof(Status), ddlStatus.SelectedValue);
                chapter.Status = statusValue;
            }
 
            CheckBoxList chkListTextModules = item.FindControl("textModulesList") as CheckBoxList;
            if (chkListTextModules != null)
            {
                foreach (ListItem chkItem in chkListTextModules.Items)
                {
                    int linkId = Int32.Parse(chkItem.Value);
 
                    if (chkItem.Selected)
                    {
                        if (chapter.Status.Value == Status.Red)
                            chapter.Status = Status.Yellow;
 
                        if (chapter.LinkId.Count(v => v.Value == linkId) == 0)
                            chapter.LinkId.Add(linkId);
                    }
                    else
                    {
                        if (chapter.LinkId.Count(v => v.Value == linkId) != 0)
                            chapter.LinkId.Remove(chapter.LinkId.Where(v => v.Value == linkId).First());
                    }
                }
            }
 
            if (!chapter.ID.HasValue)
                chapter.ItemOrder = DocumentStructure.Chapters.Where(ch => ch.ParentChapter == chapter.ParentChapter).Max(ch => ch.ItemOrder) + 1 ?? 1;
 
            chapter.Title = values["Title"] as string;
            return chapter;
        }
 
        private int? GetParentId(TreeListDataItem parent)
        {
            if (parent == null)
                return null;
            ChaptersItem parentItem = this.DocumentStructure.GetChapter(parent.GetId("ID"));
            if (parentItem == null)
                return null;
            return parentItem.ID;
        }
 
        private string GetChapterNumber(ChaptersItem item)
        {
            if (!item.ParentChapter.HasValue)
            {
                return (chapterParentIds.Values.Count(v => v == -1) + 1).ToString();
            }
            else
            {
                return itemChapterNumber[item.ParentChapter.Value] + "." + (chapterParentIds.Values.Count(v => v == item.ParentChapter.Value) + 1);
            }
        }
 
        private DataTable GetTextModulesWithCountry(IList<int?> ds)
        {
            DataTable result = new DataTable();
            result.Columns.Add("ID");
            result.Columns.Add("Title");
            result.Columns.Add("URL");
            if (ds != null)
                foreach (DataRow module in _textModules.Rows)
                {
                    int moduleId = (int)module["ID"];
                    if (ds.FirstOrDefault(r => r.Value == moduleId) != null)
                    {
                        var tmEntity = DocumentStructure.TextModules.FirstOrDefault(tm => tm.ID == moduleId);
                        if (tmEntity != null)
                            result.Rows.Add(moduleId, module["Title"], tmEntity.Path + "/" + tmEntity.Name);
                    }
                }
            return result;
        }
 
        private object GetUnusedOrOwnTextModules(IList<int?> ds)
        {
            DataTable result = new DataTable();
            result.Columns.Add("ID");
            result.Columns.Add("Title");
            foreach (DataRow module in _textModules.Rows)
            {
                if ((ds != null && ds.FirstOrDefault(r => r.Value == (int)module["ID"]) != null) || !selectedTextModules.Contains((int)module["ID"]))
                    result.Rows.Add(module["ID"], module["Title"]);
            }
            result.DefaultView.Sort = "Title";
            return result.DefaultView;
        }
 
        private void PopulateHierarchyDictionaries(ChaptersItem item)
        {
            var parentChapterId = item.ParentChapter ?? -1;
            if (!itemOrderMaxValuesByParent.ContainsKey(parentChapterId))
                itemOrderMaxValuesByParent.Add(parentChapterId, DocumentStructure.Chapters.Where(ch => ch.ParentChapter == item.ParentChapter).Max(ch1 => ch1.ItemOrder));
 
            if (!itemOrderMinValuesByParent.ContainsKey(parentChapterId))
                itemOrderMinValuesByParent.Add(parentChapterId, DocumentStructure.Chapters.Where(ch => ch.ParentChapter == item.ParentChapter).Min(ch1 => ch1.ItemOrder));
 
            if (!itemChapterNumber.ContainsKey(item.ID.Value))
            {
                itemChapterNumber.Add(item.ID.Value, GetChapterNumber(item));
            }
 
            if (!chapterParentIds.ContainsKey(item.ID.Value))
            {
                chapterParentIds.Add(item.ID.Value, parentChapterId);
            }
        }
 
        #endregion
    }
}

Marin
Telerik team
 answered on 16 Apr 2014
5 answers
1.0K+ views
Hi All,

I use radcontextmenu on a html table, the table has a row hover style applied which highlights the row when mouse hovers on it. But when right click on the row to open the context menu, the hover style disappears. I have noticed the browser default contextmenu doesn't have this issue. Please see the screenshots and css attached.

.hor-minimalist-b tbody tr:hover td
{
    background: #F3E2A9;
    color: #009;
}


Thanks in advance,

Jason
Magdalena
Telerik team
 answered on 16 Apr 2014
1 answer
331 views
I have a radgrid and I have enabled edit/insert/update. The Grid does a great job of auto generating the fields and column sizes to fix the context of the data. How do I change the Edit/Insert "Popup" for the fields that need to be larger and with scrollbars? Below is my code that builds the RadGrid - how do I get to the setup I am wanting. I want to make the Issue/Notes/CorrectiveAction fields larger and almost like a memo field. Also how do you change to position of the field in the edit popup by making the window larger and placing the fields in different location..

My Radgrid Code as it is now.


<telerik:RadGrid ID="RadGrid2" runat="server" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" DataSourceID="OpenAccessLinqDataSource1" Skin="Sunset" CellSpacing="-1" GridLines="Both" AutoGenerateEditColumn="True">
<ExportSettings ExportOnlyData="True" FileName="SystemCabCommExport">
<Excel Format="ExcelML" />
</ExportSettings>
<MasterTableView AutoGenerateColumns="False" editmode="PopUp" CommandItemDisplay="Top" DataKeyNames="ItemNum" DataSourceID="OpenAccessLinqDataSource1">
<Columns>
<telerik:GridBoundColumn DataField="ItemNum" DataType="System.Int32" FilterControlAltText="Filter ItemNum column" HeaderText="ItemNum" ReadOnly="True" SortExpression="ItemNum" UniqueName="ItemNum">
<ColumnValidationSettings>
<ModelErrorMessage Text="" />
</ColumnValidationSettings>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="_Date" DataType="System.DateTime" FilterControlAltText="Filter _Date column" HeaderText="_Date" SortExpression="_Date" UniqueName="_Date">
<ColumnValidationSettings>
<ModelErrorMessage Text="" />
</ColumnValidationSettings>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="IssueType" FilterControlAltText="Filter IssueType column" HeaderText="IssueType" SortExpression="IssueType" UniqueName="IssueType">
<ColumnValidationSettings>
<ModelErrorMessage Text="" />
</ColumnValidationSettings>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Issue" FilterControlAltText="Filter Issue column" HeaderText="Issue" SortExpression="Issue" UniqueName="Issue">
<ColumnValidationSettings>
<ModelErrorMessage Text="" />
</ColumnValidationSettings>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ReportedBy" FilterControlAltText="Filter ReportedBy column" HeaderText="ReportedBy" SortExpression="ReportedBy" UniqueName="ReportedBy">
<ColumnValidationSettings>
<ModelErrorMessage Text="" />
</ColumnValidationSettings>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ResponsiblePerson" FilterControlAltText="Filter ResponsiblePerson column" HeaderText="ResponsiblePerson" SortExpression="ResponsiblePerson" UniqueName="ResponsiblePerson">
<ColumnValidationSettings>
<ModelErrorMessage Text="" />
</ColumnValidationSettings>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Notes" FilterControlAltText="Filter Notes column" HeaderText="Notes" SortExpression="Notes" UniqueName="Notes">
<ColumnValidationSettings>
<ModelErrorMessage Text="" />
</ColumnValidationSettings>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="CorrectiveAction" FilterControlAltText="Filter CorrectiveAction column" HeaderText="CorrectiveAction" SortExpression="CorrectiveAction" UniqueName="CorrectiveAction">
<ColumnValidationSettings>
<ModelErrorMessage Text="" />
</ColumnValidationSettings>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Status" FilterControlAltText="Filter Status column" HeaderText="Status" SortExpression="Status" UniqueName="Status">
<ColumnValidationSettings>
<ModelErrorMessage Text="" />
</ColumnValidationSettings>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ClosedDate" DataType="System.DateTime" FilterControlAltText="Filter ClosedDate column" HeaderText="ClosedDate" SortExpression="ClosedDate" UniqueName="ClosedDate">
<ColumnValidationSettings>
<ModelErrorMessage Text="" />
</ColumnValidationSettings>
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
Shinu
Top achievements
Rank 2
 answered on 16 Apr 2014
1 answer
240 views
When  i change the value in a field into rad grid (<BatchEditingSettings EditType="Row" OpenEditingEvent="Click" />),  i need to click somewhere in page, for appear the red triangle in left corner of the box. Which client side events call this? 
I want to call this event in my custom function?  
var grid = $find('<%=theLineItemsGrid.ClientID%>')
grid.??????
Eyup
Telerik team
 answered on 16 Apr 2014
4 answers
224 views
Hi,
I have the following challenge and I do not know how to solve this.
When the user enter the date in a dateTime column "Date" in edit mode, I need the week number to be automatically inserted in a bound column and saved to the db.
The week number is calculated in a method from code behind:

private static int WeekOfYear(DateTime date)
    {
        var day = (int)CultureInfo.CurrentCulture.Calendar.GetDayOfWeek(date);
        return CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(date.AddDays(4 - (day == 0 ? 7 : day)), CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
    }

This is my actual grid:
<telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" Culture="it-IT" DataSourceID="SqlDataSource1" PageSize="20" CellSpacing="-1" GridLines="Both">
                        <ExportSettings>
                            <Pdf PageHeight="297mm" PageWidth="" PaperSize="A4">
                            </Pdf>
                        </ExportSettings>
                        <ClientSettings>
                            <Scrolling AllowScroll="True" UseStaticHeaders="True" />
                        </ClientSettings>
                        <MasterTableView CommandItemDisplay="Top" DataKeyNames="Id" DataSourceID="SqlDataSource1" Caption="Working Hours" >
                            <Columns>
                                <telerik:GridEditCommandColumn ButtonType="ImageButton">
                                    <HeaderStyle Width="25px" />
                                </telerik:GridEditCommandColumn>
                                <telerik:GridBoundColumn DataField="Id" DataType="System.Int32" FilterControlAltText="Filter Id column" HeaderText="Id" ReadOnly="True" SortExpression="Id" UniqueName="Id">
                                    <ColumnValidationSettings>
                                        <ModelErrorMessage Text="" />
                                    </ColumnValidationSettings>
                                    <HeaderStyle HorizontalAlign="Left" Width="35px" />
                                </telerik:GridBoundColumn>
                                <telerik:GridDateTimeColumn DataField="Date" DataFormatString="{0:dd/MM/yyyy}" FilterControlAltText="Filter Date column" HeaderText="Date" SortExpression="Date" UniqueName="Date">
                                    <ColumnValidationSettings>
                                        <ModelErrorMessage Text="" />
                                    </ColumnValidationSettings>
                                    <HeaderStyle HorizontalAlign="Center" Width="85px" />
                                </telerik:GridDateTimeColumn>
 
                                <telerik:GridTemplateColumn DataField="Pnum" FilterControlAltText="Filter Pnum column" HeaderText="P Number" SortExpression="Pnum" UniqueName="Pnum">
                                    <EditItemTemplate>
                                        <telerik:RadComboBox ID="PnumRadComboBox" runat="server" DataSourceID="SqlDataSource2" DataTextField="Pnum" DataValueField="Pnum" SelectedValue='<%# Bind("Pnum") %>'>
                                        </telerik:RadComboBox>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="PnumLabel" runat="server" Text='<%# Eval("Pnum") %>'></asp:Label>
                                    </ItemTemplate>
                                    <HeaderStyle HorizontalAlign="Center" Width="65px" />
                                </telerik:GridTemplateColumn>
 
                                <telerik:GridDateTimeColumn DataField="WorkedTime" FilterControlAltText="Filter column column" PickerType="TimePicker" DataFormatString="{0:hh\:mm}" HeaderText="Worked Time" SortExpression="WorkedTime" UniqueName="column">
                                    <ColumnValidationSettings>
                                        <ModelErrorMessage Text="" />
                                    </ColumnValidationSettings>
                                    <HeaderStyle HorizontalAlign="Center" Width="65px" />
                                </telerik:GridDateTimeColumn>
 
                                <telerik:GridBoundColumn DataField="Note" FilterControlAltText="Filter Note column" HeaderText="Note" SortExpression="Note" UniqueName="Note">
                                    <ColumnValidationSettings>
                                        <ModelErrorMessage Text="" />
                                    </ColumnValidationSettings>
                                    <HeaderStyle HorizontalAlign="Center" />
                                </telerik:GridBoundColumn>
                                <telerik:GridClientDeleteColumn ButtonType="ImageButton" FilterControlAltText="Filter column1 column" UniqueName="column1">
                                    <HeaderStyle Width="25px" />
                                </telerik:GridClientDeleteColumn>
                            </Columns>
                        </MasterTableView>
                    </telerik:RadGrid>
I would appreciate your help to solve this.
Thanks you,
Felice
Konstantin Dikov
Telerik team
 answered on 16 Apr 2014
2 answers
229 views
I am getting the following error on a form grid:

Exception type: IndexOutOfRangeException
Exception message: Cannot find table 0.
   at System.Data.DataTableCollection.get_Item(Int32 index)
   at storagePortal.shipout.RadGrid1_NeedDataSource(Object source, GridNeedDataSourceEventArgs e)
   at Telerik.Web.UI.RadGrid.OnNeedDataSource(GridNeedDataSourceEventArgs e)
   at Telerik.Web.UI.RadGrid.AutoDataBind(GridRebindReason rebindReason)
   at Telerik.Web.UI.RadGrid.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

The web page was working fine yesterday.  Nothing changed that I know of, but this error is appearing today. The data source is provided by a stored procedure that I ran separately - it works fine.  Anyone have any ideas? 


Jayesh Goyani
Top achievements
Rank 2
 answered on 16 Apr 2014
1 answer
125 views
I have 3 dropDownList in my grid, all bind to Sql tables with SqlDatasource. The first one "Pnum" acts like I need, i.e. when a value is selected it stays there even when I re-open the record for modification. The other two "minutes" and "hours" behave in a different way, I mean every time I open the record for modification, the selected value is set to the first one in the db or nothing.

This is the good one:

<EditFormSettings EditFormType="Template">
<FormTemplate>
<table class="table">
.........
<telerik:RadDropDownList ID="RadDropDownList1" runat="server"
DataSourceID="SqlDataSource2" DataTextField="Pnum" DataValueField="Pnum"
SelectedValue='<%#Bind("Pnum") %>' Skin="Outlook" AutoPostBack="true">
</telerik:RadDropDownList>


These two give me the problem:

<telerik:RadDropDownList ID="RadDropDownList2" runat="server" DataSourceID="SqlDataSource3"
DataTextField="minutes" DataValueField="minutes" SelectedValue='<%#Bind("minutes") %>'
Skin="Outlook" AutoPostBack="true">
</telerik:RadDropDownList>
 
<telerik:RadDropDownList ID="RadDropDownList3" runat="server" DataSourceID="SqlDataSource4"
DataTextField="hours" AutoPostBack="false" DataValueField="hours"
SelectedValue='<%#Bind("hours") %>' Skin="Outlook">
</telerik:RadDropDownList>
.......
</table>
 </FormTemplate>
</EditFormSettings>


I do not see any difference that may cause such different behavior. Any hint on how to solve this problem? I mean, avoid that the value is changed when opening the record for modification.
Princy
Top achievements
Rank 2
 answered on 16 Apr 2014
20 answers
1.2K+ views
Hi all,

http://www.telerik.com/help/aspnet/grid/grddefaulteditmodeforgriditemsoninitialload.html


foreach(GridItem item in RadGrid1.MasterTableView.Items)
 {
  
if (item is GridEditableItem)
  {
   GridEditableItem editableItem= item
as GridDataItem;
   editableItem.Edit = true;
  }
 }
 RadGrid1.Rebind();


i am using the method in the above link to make my Radgrid editable on click of a button.
But.. this is not working... in fact when i click on another button t change it back to normal mode...it now appears in edit mode.!!!

can anyone help me?
Thanks in advance
John
Shinu
Top achievements
Rank 2
 answered on 16 Apr 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?