Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
112 views
Drag and drop ability suddenly stopped working with the release 2012.1.411.40 back in April 2012. Well, I found that the issue is because the RadScheduler had the settings <MonthView ReadOnly="true">. If I change it to <MonthView ReadOnly="false"> or remove it, I can drag and drop again. However, now my appointments have a red X that will bring up a cancel window.

Is there a way to remove the red X from an appointment?

I have a context menu that offers the delete menu item, and I want to keep it. But I don't want the red X to show on the appointment.

Thanks for any info,
Robert


Robert Helm
Top achievements
Rank 1
 answered on 13 Jul 2012
4 answers
157 views
Hi,

   i am using Rad tab strip control in my screen and when i use Rad date time picker and Recurrence control inside the tab.
the control design is collapsed please verify the screen shots and give me a solution as soon as possible

FYI:
      Telerik DLL Version :2011.1.519.35
       Browser  : IE8
Vidthi
Top achievements
Rank 1
 answered on 13 Jul 2012
1 answer
103 views
Hi,

We use Telerik RadGrid in our ASP.NET application. The Oracle database is our main data source. But, we also use the application cache as another data source. The application cache is implemented as static class that use internal dictionary.

When we use the application cache as data source we have 2 grids: first one is master and second one is detail, which means when we select some item in master grid it reflects in detail grid below. It's regular scenario and it works fine.

We have 2 buttons in small toolbar above each grid, remove button and refresh button. Everything works fine in master grid, which means when we select item(s) they are removed and the content of grid is refreshed immediately by code.

The thing that is not working is refreshing the detail grid. We select item(s) and click delete button in small toolbar. The items actually were deleted from underlying cache, but the content of grid is not refreshed. When we click refresh button in master grid and select item in master grid that refers to detail grid we can see new content without deleted items in detail grid. In this way we know the items in detail grid have been deleted. But, we need to refresh the content immediately.

The code that is responsible for deleting and refreshing is fairly complex (I haven't written that code) and I want to delete the selected items in detail grid not only in underlying cache, but physically from the grid as well. How can I do that?

Thank you in advance.

Goran
Elliott
Top achievements
Rank 2
 answered on 13 Jul 2012
3 answers
93 views
Hello,

Could somebody help me to solve my issue ? I've exported data from hierarched grid to Excel. Export is done properly, but in the result .xls file there are some rows which have text No child records to display. These rows I don't want to include in the export...

RadGrid export declaration is:
<ExportSettings Excel-Format="Html" ExportOnlyData="true" IgnorePaging="true"
                OpenInNewWindow="true">
            </ExportSettings>

I've tried to hide them in server code methods, e.g. RadGrid1_ItemCreated or RadGrid1_ExportCellFormatting, empty row text is still there :(.

Please help me to solve my issue.

For further information, please check the attachment.
The question is, how to remove rows 9 and 22 from exported xls...

Best regards

Vasssek
Milena
Telerik team
 answered on 13 Jul 2012
3 answers
107 views
I've tried to make this work correctly using multiple methods, however when a user would click the Edit Button on one of the Internal RadGrid items it loses track of the row that is being edited. Thus shows in the background all possible rows, and does not know what the values were of the record being edited.

Attached is the ASPX and Code Behind for reference.

<%@ Page Title="" Language="C#" AutoEventWireup="true" CodeBehind="Test2.aspx.cs"
    Inherits="mtc_knowledgebase.Test2" %>
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<head id="Head1" runat="server">
    <style type="text/css">
        span.riSingle
        {
            position: static;
        }
    </style>
</head>
<body class="BODY">
    <form runat="server" id="mainForm" method="post">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
    <telerik:RadGrid AllowSorting="True" AutoGenerateColumns="False" DataSourceID="DNDataSource"
        ID="DNGrid" runat="server" GridLines="Both" AllowPaging="true" AllowFilteringByColumn="true"
        CssClass="span.riSingle" OnItemCommand="DNGrid_OnItemCommand">
        <MasterTableView CommandItemDisplay="Bottom" DataKeyNames="dn_hdr_id" EditMode="PopUp"
            Name="HeaderGrid" AllowAutomaticInserts="true" AllowAutomaticUpdates="true">
            <NestedViewTemplate>
                <asp:Panel runat="server" ID="InnerContainer">
                    <telerik:RadTabStrip runat="server" ID="TabStip1" MultiPageID="Multipage1" SelectedIndex="0"
                        DataFieldParentID="dn_hdr_id">
                        <Tabs>
                            <telerik:RadTab runat="server" Text="DN Items" PageViewID="ItemView">
                            </telerik:RadTab>
                            <telerik:RadTab runat="server" Text="DN Approvals" PageViewID="ApprovalView">
                            </telerik:RadTab>
                        </Tabs>
                    </telerik:RadTabStrip>
                    <telerik:RadMultiPage runat="server" ID="Multipage1" SelectedIndex="0" RenderSelectedPageOnly="false">
                        <telerik:RadPageView runat="server" ID="ItemView">
                            <telerik:RadGrid AllowSorting="True" AutoGenerateColumns="False" DataSourceID="DNDtlDataSource"
                                ID="DetailGrid" runat="server" GridLines="Both" CssClass="span.riSingle" BackColor="Azure"
                                HeaderStyle-ForeColor="DimGray" HeaderStyle-BorderColor="DarkGoldenrod" HeaderStyle-BorderWidth="2px"
                                OnInsertCommand="GridOnInsert" OnUpdateCommand="GridOnUpdate" OnItemCommand="GridGetId">
                                <MasterTableView CommandItemDisplay="Bottom" DataKeyNames="dn_dtl_id,dn_hdr.dn_hdr_id"
                                    EditMode="PopUp" Name="DetailGrid">
                                    <CommandItemSettings ShowExportToExcelButton="false" ShowRefreshButton="false" AddNewRecordText="Add New Detail Record" />
                                    <EditFormSettings EditColumn-ButtonType="PushButton" EditColumn-UpdateText="Process Update"
                                        PopUpSettings-Modal="true" PopUpSettings-Width="85%" />
                                    <Columns>
                                        <telerik:GridBoundColumn UniqueName="DTL_DN_DTL_ID" DataField="dn_dtl_id" ReadOnly="true"
                                            Visible="false" />
                                        <telerik:GridEditCommandColumn EditText="EDIT" UniqueName="btnEdit" ButtonType="PushButton" />
                                        <telerik:GridAttachmentColumn DataSourceID="DNDtlDataSource2" MaxFileSize="10485760"
                                            EditFormHeaderTextFormat="Upload File:" HeaderText="Attachment" AttachmentDataField="dn_file_att"
                                            AttachmentKeyFields="dn_dtl_id" FileNameTextField="dn_file_nm" DataTextField="dn_file_nm"
                                            UniqueName="DTL_AttachmentColumn" AllowedFileExtensions=".pdf,.jpg" />
                                        <telerik:GridBoundColumn UniqueName="DTL_CREAT_BY" HeaderText="Created By" DataField="creat_by"
                                            ReadOnly="true" />
                                        <telerik:GridBoundColumn UniqueName="DTL_CREAT_DT" HeaderText="Date Created" DataField="creat_dt"
                                            ReadOnly="true" DataFormatString="{0:MM/dd/yy}" />
                                        <telerik:GridBoundColumn UniqueName="DTL_UPDT_BY" HeaderText="Last Updated By" DataField="updt_by"
                                            ReadOnly="true" />
                                        <telerik:GridBoundColumn UniqueName="DTL_UPDT_DT" HeaderText="Last Updated" DataField="updt_dt"
                                            DataFormatString="{0:MM/dd/yy}" ReadOnly="true" />
                                    </Columns>
                                </MasterTableView>
                            </telerik:RadGrid>
                        </telerik:RadPageView>
                        <telerik:RadPageView runat="server" ID="ApprovalView">
                            <telerik:RadGrid AllowSorting="True" AutoGenerateColumns="False" ID="ApprovalGrid"
                                DataSourceID="DNDataSource2" runat="server" GridLines="Both" CssClass="span.riSingle"
                                BackColor="Azure" EnableViewState="true" HeaderStyle-ForeColor="DimGray" HeaderStyle-BorderColor="DarkGoldenrod"
                                HeaderStyle-BorderWidth="2px">
                                <MasterTableView CommandItemDisplay="Bottom" DataKeyNames="dn_hdr_id" EditMode="PopUp"
                                    Name="ApprovalGridMaster">
                                    <CommandItemSettings ShowExportToExcelButton="false" ShowRefreshButton="false" ShowAddNewRecordButton="false" />
                                    <EditFormSettings EditColumn-ButtonType="PushButton" EditColumn-UpdateText="Process Update"
                                        PopUpSettings-Modal="true" PopUpSettings-Width="85%" />
                                    <Columns>
                                        <telerik:GridEditCommandColumn EditText="EDIT" UniqueName="btnEdit" ButtonType="PushButton" />
                                        <telerik:GridBoundColumn UniqueName="QR_NM" HeaderText="Quality Signoff" DataField="qr_nm" />
                                        <telerik:GridDateTimeColumn UniqueName="QR_DT" HeaderText="Quality Signoff Date"
                                            DataField="qr_dt" DataFormatString="{0:MM/dd/yy}" />
                                    </Columns>
                                </MasterTableView>
                            </telerik:RadGrid>
                        </telerik:RadPageView>
                    </telerik:RadMultiPage>
                </asp:Panel>
            </NestedViewTemplate>
            <Columns>
                <telerik:GridEditCommandColumn EditText="EDIT" UniqueName="btnEdit" ButtonType="PushButton" />
                <telerik:GridBoundColumn UniqueName="dn_hdr_id" HeaderText="DN ID" DataField="dn_hdr_id"
                    ReadOnly="true" />
                <telerik:GridBoundColumn UniqueName="SUP_NM" HeaderText="Operator/Supervisor" DataField="sup_nm" />
                <telerik:GridDateTimeColumn UniqueName="SUP_DT" HeaderText="O/S Date" DataField="sup_dt"
                    DataFormatString="{0:MM/dd/yy}" />
            </Columns>
        </MasterTableView>
        <ClientSettings AllowKeyboardNavigation="true">
            <Scrolling AllowScroll="true" ScrollHeight="600px" />
        </ClientSettings>
        <ExportSettings ExportOnlyData="true" IgnorePaging="true" />
    </telerik:RadGrid>
    <asp:EntityDataSource ID="DNDataSource" runat="server" ConnectionString="name=mtc_kbaseEntities"
        DefaultContainerName="mtc_kbaseEntities" EntitySetName="dn_hdr" OrderBy="it.updt_dt"
        Include="cust, prt, orig_1" EnableInsert="true" EnableUpdate="true">
    </asp:EntityDataSource>
    <asp:EntityDataSource ID="DNDataSource2" runat="server" ConnectionString="name=mtc_kbaseEntities"
        DefaultContainerName="mtc_kbaseEntities" EntitySetName="dn_hdr" EnableUpdate="true">
    </asp:EntityDataSource>
    <asp:EntityDataSource ID="DNDtlDataSource2" runat="server" ConnectionString="name=mtc_kbaseEntities"
        DefaultContainerName="mtc_kbaseEntities" EntitySetName="dn_dtl">
    </asp:EntityDataSource>
    <asp:EntityDataSource ID="DNDtlDataSource" runat="server" ConnectionString="name=mtc_kbaseEntities"
        DefaultContainerName="mtc_kbaseEntities" EntitySetName="dn_dtl" Include="orig_2">
    </asp:EntityDataSource>
    </form>
</body>
</html>

Code Behind
using System;
using System.Data;
using System.Linq;
using System.Web;
using Telerik.Web.UI;
  
namespace mtc_knowledgebase
{
    public partial class Test2 : System.Web.UI.Page
    {
        #region Variables
        private int _dnHdrId;
        private int _dnDtlId;
        private string _fileName;
        private byte[] _fileData;
        private string _curUser;
        private DateTime? _curDt;
        private int _errLevel;
        #endregion
        protected void Page_Load(object sender, EventArgs e)
        {
            DNDtlDataSource2.Where = "it.dn_dtl_id == 0";
        }
  
        /// <summary>
        /// This will be used in place of the auto insert event based on File Attachment requirements
        /// </summary>
        /// <param name="sender">
        /// This method is called on the Grid Insert Event
        /// </param>
        /// <param name="e">
        /// The entire Inserted record will be passed
        /// </param>
        protected void GridOnInsert(object sender, GridCommandEventArgs e)
        {
            if ("DetailGrid".Equals(e.Item.OwnerTableView.Name))
            {
                var editItem = e.Item as GridEditableItem;
                GetRecordInfo(editItem);
                if (_errLevel == 0)
                {
                    try
                    {
                        using (var db = new mtc_kbaseEntities())
                        {
                            var newDnDtl = new dn_dtl
                            {
                                dn_hdrReference = { EntityKey = new EntityKey("mtc_kbaseEntities.dn_hdr", "dn_hdr_id", _dnHdrId) },
                                dn_file_nm = _fileName,
                                dn_file_att = _fileData,
                                creat_by = _curUser,
                                creat_dt = _curDt,
                                updt_by = _curUser,
                                updt_dt = _curDt
                            };
                            db.AddTodn_dtl(newDnDtl);
                            db.SaveChanges();
                        }
                    }
                    catch (Exception ex)
                    {
                        Response.Write("<script type=\"text/javascript\" language=\"javascript\">");
                        Response.Write("alert('" + ex.Message + "');");
                        Response.Write("</script>");
                    }
                }
            }
        }
  
        /// <summary>
        /// This will be used in place of the auto update event based on File Attachment requirements
        /// </summary>
        /// <param name="sender">
        /// This method is called on the Grid Update Event
        /// </param>
        /// <param name="e">
        /// The entire Updated record will be passed
        /// </param>
        protected void GridOnUpdate(object sender, GridCommandEventArgs e)
        {
            if ("DetailGrid".Equals(e.Item.OwnerTableView.Name))
            {
                var editItem = e.Item as GridEditableItem;
                _dnDtlId = Convert.ToInt32((editItem.EditManager.GetColumnEditor("DTL_DN_DTL_ID") as GridTextBoxColumnEditor).Text);
                GetRecordInfo(editItem);
                if (_errLevel == 0)
                {
                    try
                    {
                        using (var db = new mtc_kbaseEntities())
                        {
                            var updDtl = db.dn_dtl.First(t => t.dn_dtl_id == _dnDtlId);
                            updDtl.dn_file_nm = _fileName;
                            updDtl.dn_file_att = _fileData;
                            updDtl.updt_by = _curUser;
                            updDtl.updt_dt = _curDt;
                            db.SaveChanges();
                        }
                    }
                    catch (Exception ex)
                    {
                        Response.Write("<script type=\"text/javascript\" language=\"javascript\">");
                        Response.Write("alert('" + ex.Message + "');");
                        Response.Write("</script>");
                    }
                }
            }
        }
  
        /// <summary>
        /// If a request for the file download is initiated, this will update the datasource
        /// </summary>
        /// <param name="sender">
        /// The datasource for the attachment requires the ID of the record
        /// </param>
        /// <param name="e">
        /// Only fire the event if it's a download request
        /// </param>
        protected void GridGetId(object sender, GridCommandEventArgs e)
        {
            if (e.CommandName == "DownloadAttachment")
            {
                var args = e as GridDownloadAttachmentCommandEventArgs;
                _dnDtlId = (int)args.AttachmentKeyValues["dn_dtl_id"];
                DNDtlDataSource2.Where = "it.dn_dtl_id == " + _dnDtlId;
            }
        }
  
        /// <summary>
        /// This is a common method for setting variables based on the attachment details
        /// </summary>
        /// <param name="editItem">
        /// The edit item.
        /// </param>
        protected void GetRecordInfo(GridEditableItem editItem)
        {
            _errLevel = 0;
            RadUpload upload = ((GridAttachmentColumnEditor)editItem.EditManager.GetColumnEditor("DTL_AttachmentColumn")).RadUploadControl;
            if (upload.InvalidFiles.Count > 0)
            {
                _errLevel = 1;
                Response.Write("<script type=\"text/javascript\" language=\"javascript\">");
                Response.Write("alert('Only PDF or JPG files smaller than 10MB are allowed');");
                Response.Write("</script>");
                return;
            }
  
            if (upload.UploadedFiles.Count != 0)
            {
                _fileName = upload.UploadedFiles[0].GetName();
                _fileData = ((GridAttachmentColumnEditor)editItem.EditManager.GetColumnEditor("DTL_AttachmentColumn")).UploadedFileContent;
            }
  
            _curUser = HttpContext.Current.User.Identity.Name.ToString().Replace("MORGANGROUPPLC\\", string.Empty);
            _curDt = DateTime.Now;
        }
  
        protected void DNGrid_OnItemCommand(object sender, GridCommandEventArgs e)
        {
            GridDataItem grdDataitem = (GridDataItem)e.Item;
  
            if (e.CommandName == RadGrid.ExpandCollapseCommandName)
            {
                _dnHdrId = (int)grdDataitem.GetDataKeyValue("dn_hdr_id");
                DNDtlDataSource.Where = "it.dn_hdr.dn_hdr_id == " + _dnHdrId;
                DNDataSource2.Where = "it.dn_hdr_id == " + _dnHdrId;
            }
        }
    }
}
Andrey
Telerik team
 answered on 13 Jul 2012
1 answer
115 views
I am trying to set the WorkDayStartTime and WorkDayEndTime properties when the page first loads with values stored in my web.config.  I have tried to set in bot the page onInit and onLoad events to set these values, but they effect of setting the values doesn't show when the page initally loads, but it will display properly after a postback.  Is there some way to get these settings to take affect when the page first loads.  The setting of DayStartTime and DayEndTime work correctly.
Ivana
Telerik team
 answered on 13 Jul 2012
0 answers
51 views
Is there any way to export radgrid in image (jpg, bmp etc), instead of pdf, excel, csv etc?
Munish
Top achievements
Rank 1
 asked on 13 Jul 2012
0 answers
150 views
I am using below code to avoid prompting for filename/path, while exporting telerik grid. In this if I remove last line response.redirect then it again started asking for filename/path. Can you please suggest any other way, because i dont to perform response.redirect after this action?


protected void RadGridData_GridExporting(object source, GridExportingArgs e)
        {
            string gridfile = "c:\\grid.pdf";
            files.Add(gridfile);
            using (FileStream fs = File.Create(gridfile))
            {
                Byte[] info = System.Text.Encoding.Default.GetBytes(e.ExportOutput);
                fs.Write(info, 0, info.Length);
            }
            Response.Redirect(Request.Url.ToString());
        }
Munish
Top achievements
Rank 1
 asked on 13 Jul 2012
1 answer
135 views
I'm having some problem getting a repeater with a nested repeater update with ajaxmanger.

Se example page here: http://dev12.spireweb.no/repeater_ajax.aspx 

I just want the nested repeater in the post to update when a comment this added or deleted. This only works for the first post.
Is there a way to solved this issue?

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="btnRefreshPosts" EventName="onclick">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="pnlPosts" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="repPosts" EventName="onitemcommand">
                    <UpdatedControls>                   
                        <telerik:AjaxUpdatedControl ControlID="pnlComments" />                 
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="repComments" EventName="onitemcommand">
                    <UpdatedControls>                   
                        <telerik:AjaxUpdatedControl ControlID="pnlComments" />                 
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>


<asp:Panel ID="pnlPosts" runat="server">
                   <div id="Posts" style="padding:10px;margin:15px; width:700px;">
                       <asp:Repeater ID="repPosts" runat="server" onitemdatabound="repPosts_ItemDataBound" OnItemCommand="repPosts_ItemCommand">
                           <ItemTemplate>
                               <div class="postitem" >
                                   <div class="sep"></div>
                                   <div class="postitem_name" >
                                       <asp:Literal ID="litName" runat="server" />
                                       <asp:Literal ID="litCreated" runat="server" />                                   
                                   </div>
                                   <div class="postitem_content">
                                       <asp:Button ID="btnDelete" runat="server" Text="" CssClass="btnDelete" />
                                       <asp:Literal ID="litContent" runat="server" />
                                   </div>                                   
                               </div>
                               <div style="clear:both;"></div>
                                   <asp:Panel ID="pnlComments" runat="server">
                                   <div class="CommentsWrapper">
                                       <asp:Repeater ID="repComments" runat="server" OnItemDataBound="repComments_ItemDataBound" OnItemCommand="repComments_ItemCommand">
                                           <HeaderTemplate>
                                                   <h3>Comments</h3>
                                           </HeaderTemplate>
                                           <ItemTemplate>
                                                   <div class="Comment">       
                                                       <asp:Button ID="btnDelete" runat="server" Text="" CssClass="btnDelete" />                                       
                                                       <asp:Literal ID="litComment" runat="server" />                                               
                                                   </div>
                                           </ItemTemplate>
                                       </asp:Repeater>
                                       <div class="AddComment">
                                           <asp:Panel ID="pnlAddComment" runat="server" DefaultButton="btnAddComment">
                                               <asp:TextBox ID="txtComment" runat="server"></asp:TextBox>
                                               <asp:Button ID="btnAddComment" CssClass="common btnAddComment" runat="server" Text="Submit" />
                                           </asp:Panel>
                                       </div>
                                       <div style="clear:both;"></div>
                                   </div>
                               </asp:Panel>
                           </ItemTemplate>                   
                       </asp:Repeater>
                   </div>
               </asp:Panel>


protected void GetPosts()
    {
        repPosts.DataSource = WineclubManager.GetPosts(19,20);
        repPosts.DataBind();
    }
    protected void repPosts_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
        {
            PostItem row = (PostItem)(e.Item.DataItem);
            CustomerItem customer = CustomerManager.GetCustomer(row.CustomerID);
            Repeater repComments = (Repeater)e.Item.FindControl("repComments");
 
            Literal litName = (Literal)e.Item.FindControl("litName");
            Literal litCreated = (Literal)e.Item.FindControl("litCreated");
            Literal litContent = (Literal)e.Item.FindControl("litContent");
            TextBox txtComment = (TextBox)e.Item.FindControl("txtComment");
 
            Button btnAddComment = (Button)e.Item.FindControl("btnAddComment");
            Button btnDelete = (Button)e.Item.FindControl("btnDelete");
 
            if (row.CustomerID != 0)
                litName.Text = "<span>" + customer.Firstname + " " + customer.Lastname + "</span>";
            else
                litName.Text = "<span>LabelWines</span>";
 
            litCreated.Text = "<span class=\"date\">" + row.Created.ToString("dd.MM.yyyy HH:mm") + "</span>";
            litContent.Text = row.Content;
 
            txtComment.Text = "Write a comment";
 
            if (row.CustomerID == CustomerManager.GetCustomerID())
            {
                btnDelete.CommandName = "Delete";
                btnDelete.CommandArgument = row.ID.ToString();
                btnDelete.Attributes.Add("onclick", "jConfirm('" + Resources.Language.Wineclub_PostPopupMessage.Replace(Environment.NewLine, "<br />") + "', '" + Resources.Language.Wineclub_PostPopupHeader + "', function(r) { if(r==true) __doPostBack(\"" + btnDelete.ClientID.Replace("_", "$") + "\", \"\"); }); return false;");
            }
            else
                btnDelete.Visible = false;
 
            btnAddComment.CommandName = "AddComment";
            btnAddComment.CommandArgument = row.ID.ToString();
            BindInnerRepeaterComments(repComments, row.ID);
        }
    }
    protected void repPosts_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        switch (e.CommandName)
        {
            case "AddComment":
                CommentItem item = new CommentItem();
                item.PostID = int.Parse(e.CommandArgument.ToString());
                item.CustomerID = 2;
 
                TextBox txtComment = e.Item.FindControl("txtComment") as TextBox;
                if ((txtComment.Text.Length > 0) && (txtComment.Text != "Write a comment"))
                    item.Comment = txtComment.Text;
                int id = WineclubManager.AddComment(item);
 
                txtComment.Text = Resources.Language.Wineclub_PostDefaultCommentText;
                Repeater repComments = (Repeater)e.Item.FindControl("repComments");
                BindInnerRepeaterComments(repComments, int.Parse(e.CommandArgument.ToString()));
 
                RadAjaxManager ra = (RadAjaxManager)(Page.FindControl("RadAjaxManager1"));
                ra.ResponseScripts.Add("javascript:InitCommentTextFields();");
                 
                break;
        }
        switch (e.CommandName)
        {
            case "Delete":
                WineclubManager.DeletePost(int.Parse(e.CommandArgument.ToString()));
                GetPosts();
 
                RadAjaxManager ra = (RadAjaxManager)(Page.FindControl("RadAjaxManager1"));
                ra.ResponseScripts.Add("javascript:InitCommentTextFields();");
                ra.ResponseScripts.Add("javascript:YoutubePosts();");
                break;
        }
    }
    private void BindInnerRepeaterComments(Repeater Rep, int PostID)
    {
        CommentCollection items = WineclubManager.GetComments(PostID, false);
        if (items.Count > 0)
        {
            Rep.DataSource = items;
            Rep.DataBind();
            Rep.Visible = true;
        }
        else
            Rep.Visible = false;
    }
    protected void repComments_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
        {
            CommentItem row = (CommentItem)e.Item.DataItem;
            CustomerItem customer = CustomerManager.GetCustomer(row.CustomerID);
 
            Literal litComment = (Literal)e.Item.FindControl("litComment");
            Button btnDelete = (Button)e.Item.FindControl("btnDelete");
 
            litComment.Text = "<span class=\"commentname\">" + customer.Firstname + " " + customer.Lastname + " - </span><span class=\"commentdate\">" + row.Created.ToString("dd.MM.yyyy HH:mm") + "</span>" + "<span class=\"commentmessage\">" + row.Comment + "</span>";
 
            if (row.CustomerID == 2)
            {
                btnDelete.CommandName = "Delete";
                btnDelete.CommandArgument = row.ID.ToString();
                btnDelete.Attributes.Add("onclick", "jConfirm('" + Resources.Language.Wineclub_PostCommentPopupMessage.Replace(Environment.NewLine, "<br />") + "', '" + Resources.Language.Wineclub_PostCommentPopupHeader + "', function(r) { if(r==true) __doPostBack(\"" + btnDelete.ClientID.Replace("_", "$") + "\", \"\"); }); return false;");
            }
            else
                btnDelete.Visible = false;
 
        }
    }
    protected void repComments_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        CommentItem currentComment = WineclubManager.GetComment(int.Parse(e.CommandArgument.ToString()));
        Repeater currentRep = (Repeater)source;
        switch (e.CommandName)
        {
            case "Delete":
                WineclubManager.DeleteComment(int.Parse(e.CommandArgument.ToString()));
                //GetPosts();
 
                BindInnerRepeaterComments(currentRep, currentComment.PostID);
 
                RadAjaxManager ra = (RadAjaxManager)(Page.FindControl("RadAjaxManager1"));
                ra.ResponseScripts.Add("javascript:InitCommentTextFields();");
 
                break;
        }
    }

Maria Ilieva
Telerik team
 answered on 13 Jul 2012
4 answers
74 views
Hi,

there is a strange behavior that I can't understand when I DoubleClick on a row.

Here is my javacript function that handle the RowDblClick:

var editedRowIndex;
function RowDblClick(sender, eventArgs)
{
    var gridMPA = $find("<%= gridMPA.ClientID %>");
    var editedRow;
     
    if (editedRowIndex)
    {
        editedRow = gridMPA.get_masterTableView().get_dataItems()[editedRowIndex];
        if (editedRow.get_isInEditMode())
        {
            gridMPA.get_masterTableView().updateItem(editedRow.get_itemIndexHierarchical());
        }
    }
    editedRowIndex = eventArgs.get_itemIndexHierarchical();
    gridMPA.get_masterTableView().editItem(editedRowIndex);
}

If you look at it, is seems to works and it does, but only in chrome debug. If I just run it normally, the editedRow doesn't get updated, but if I run it in debug using Chrome debug and execute line per line, it works. So why this is happenning?

Thanks.
Andrey
Telerik team
 answered on 13 Jul 2012
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?