This is a migrated thread and some comments may be shown as answers.

Rating doesn't fire when i change to page on radgrid

5 Answers 119 Views
Rating
This is a migrated thread and some comments may be shown as answers.
Gökhan
Top achievements
Rank 1
Gökhan asked on 25 Jun 2012, 10:28 AM
Hi,

I have a radgrid and it has 2 column. last coumn is template column which has radrating control. I can use and rate when i open first time to the grid. Then I change to page and on second page I can't rate my rate control. And I is not showing selecting animation. 

I attached my source codes and screen shots. Please let me know how can I fix it. This project publised and this bug waiting for fix :(

ps: I check javascript errors on google chorme, Problem is not javascript. I saw no error in javascript.

Thanks..

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="InsertKeywordAndWeight.ascx.cs" Inherits="Sections_TaskManagement_InsertKeywordAndWeight" %>
 
<telerik:RadAjaxManager ID="RadAjaxManager2" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="btnAdd">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGridKeyword" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="RadGridKeyword">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGridKeyword" LoadingPanelID="RadAjaxLoadingPanel1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
     </AjaxSettings>
</telerik:RadAjaxManager>
 
<telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel1" Skin="Hay" />
<div style="width:500px; padding:5px;">
    <div style="width:490px; margin-top:25px; padding:2px; float:left; display:block;">
        <asp:Label ID="lblKeywordDesc" Text="Eklemek İstediğiniz Anahtar Kelimeyi Giriniz:" runat="server"></asp:Label>
    </div>
    <div style="width:490px; margin-bottom:5px; padding:2px; float:left; display:block;">
        <asp:TextBox runat="server" ID="txtNewKeyWord" Width="90%" style="float:left;"></asp:TextBox><br />
        <telerik:RadRating ID="RadRating1" runat="server" Value='4' Precision="Exact" style="float:left;" /><asp:ImageButton style="float:left; margin:5px; padding:0 5px 0 0;" runat="server" ID="btnAdd" OnClick="btnAdd_Click" ImageUrl="~/images/add2.png" />
    </div>
    <div style="width:490px; padding:2px; margin-top:5px; float:left; display:block;">
        <telerik:RadGrid ID="RadGridKeyword" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource" ViewStateMode="Enabled"  PageSize="5" AllowPaging="true" AllowAutomaticDeletes="True"
                        AllowAutomaticInserts="True" AllowAutomaticUpdates="True"  AllowSorting="true" AutoGenerateColumns="false" AllowFilteringByColumn="true" OnItemCommand="RadGridKeyword_ItemCommand">
            <MasterTableView TableLayout="Auto">
                <Columns>
                <telerik:GridBoundColumn  DataField="IntCode" UniqueName="IntCode"  Visible="false" />
                    <telerik:GridBoundColumn HeaderText="Anahtar Kelime" DataField="Keyword" UniqueName="AddKeyword" AllowSorting="true"
                            SortExpression="AddKeyword" HeaderStyle-Width="40%" FilterControlWidth="100%" ItemStyle-Width="40%"
                            AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" />
                    <telerik:GridBoundColumn HeaderText="İçerik Adı" AllowFiltering="false" ShowFilterIcon="false" AutoPostBackOnFilter="true" AllowSorting="true" DataField="AddressOfKeyWordFieldName" UniqueName="AddressOfKeyWordFieldName"
                            SortExpression="AddressOfKeyWordFieldName" HeaderStyle-Width="10%" FilterControlWidth="10%" ItemStyle-Width="10%" />                   
                    <telerik:GridTemplateColumn HeaderText="Derece" ShowFilterIcon="false"  AllowFiltering="false"  HeaderStyle-Width="20%" FilterControlWidth="20%" ItemStyle-Width="20%">
                        <ItemTemplate>
                            <telerik:RadRating ID="RadRating1" runat="server"  AutoPostBack="true" OnRate="RadRating1_Rate" Value='<%# (Getron.Core.Tools.DataTableFieldOperation.ToDecimal(Eval("KeyWordWeight").ToString(),0)/20) %>' Precision="Exact" />
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn  UniqueName="DeleteButton" HeaderText="Sil" ShowFilterIcon="false"  Groupable="False" AllowFiltering="false" Resizable="False"  HeaderStyle-Width="5%" FilterControlWidth="5%" ItemStyle-Width="5%">
                        <ItemTemplate>
                            <asp:HiddenField runat="server" ID="hdnIntCode" Value='<%# Eval("Intcode").ToString() %>' />
                            <asp:ImageButton style="float:left; margin:5px; padding:2px 5px 6px 0;" runat="server" ID="btnDeleteKeyword" CommandName="Delete" CommandArgument='<%# Eval("IntCode").ToString() %>' ImageUrl="~/images/delete2.png" />
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>       
    </div>
</div>



public partial class Sections_TaskManagement_InsertKeywordAndWeight : EntityProtectedUserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
 
             
    }
 
    protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        KeywordRelation kRel = new KeywordRelation();
        QueryEntity qEntity = new QueryEntity();
        qEntity.Query = string.Format("ReferancedTable = {0} AND ReferancedKey = {1}", "30002", Request.QueryString["ActiveRecordIntCode"].ToString());
        KeywordDT = kRel.GetTableActive(qEntity);
        RadGridKeyword.DataSource = KeywordDT;
    }
 
 
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        Keyword keyword = new Keyword();
        KeywordRelation rel = new KeywordRelation();
        keyword.DbSession.BeginTransaction();
        rel.DbSession.BeginTransaction();
        try
        {
            long keyWordIntCode = 0;
            QueryEntity qentity = new QueryEntity();
            qentity.Query = string.Format("Keyword = '{0}'", txtNewKeyWord.Text);
            DataTable dtKeyword = keyword.GetTableActive(new List<string>() { "IntCode", "Keyword" }, qentity);
            if (dtKeyword.Rows.Count > 0)
                keyWordIntCode = Getron.Core.Tools.DataTableFieldOperation.ToInt64(dtKeyword.Rows[0]["Intcode"].ToString(), 0);
            else
            {
                keyword.Keywords = txtNewKeyWord.Text;
                keyword.WithMakerChecker = false;
                keyword.Save(this.Page.SystemUser.UserIntCode);
                keyWordIntCode = keyword.ProcessingRowIntCode;
            }
 
 
            rel.KeyWordIntCode = keyWordIntCode;
            rel.KeyWordWeight = Getron.Core.Tools.DataTableFieldOperation.ToInt32(((RadRating1.Value * 10) * 2), 60);
            rel.AddressOfKeyWordNumCode = 46;
            rel.ReferancedFieldNumCode = 1;
            rel.ReferancedKey = Getron.Core.Tools.DataTableFieldOperation.ToInt64(Request.QueryString["ActiveRecordIntCode"].ToString(), 0);
            rel.WithMakerChecker = false;
            rel.Save(this.Page.SystemUser.UserIntCode);
 
            keyword.DbSession.Commit();
            rel.DbSession.Commit();
            RadAjaxManager2.Alert("Anahtar Başarıyla Eklendi.");
 
            
        }
        catch (Exception ex)
        {
            try
            {
                keyword.DbSession.Rollback();
                rel.DbSession.Rollback();
            }
            catch
            {
            }
            RadAjaxManager2.Alert("Anahtar Eklenirken Hata Oluştu.");
        }
    }
 
    protected void RadGridKeyword_ItemCommand(object sender, GridCommandEventArgs e)
    {
        try
        {
            if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
            {
                if (e.CommandName == "Delete")
                {
                    ImageButton img = (ImageButton)e.Item.FindControl("btnDeleteKeyword");
                    if (img != null)
                    {
                        HiddenField hdnIntCode = (HiddenField)e.Item.FindControl("hdnIntCode");
                        if (hdnIntCode != null)
                        {
                            KeywordRelation kr = new KeywordRelation(Getron.Core.Tools.DataTableFieldOperation.ToInt64(hdnIntCode.Value, 0));
                            kr.WithMakerChecker = false;
                            kr.Delete(this.Page.SystemUser.UserIntCode);
 
                            RadGridKeyword.Rebind();
 
                            RadAjaxManager2.Alert("Silindi.");
                        }
                    }
                }
                else
                {
                    RadRating rate = (RadRating)e.Item.FindControl("RadRating1");
                }
            }
        }
        catch (Exception ex)
        {
            RadAjaxManager2.Alert("Silinirken Hata Alındı.");
        }
    }
 
    protected void RadRating1_Rate(object sender, EventArgs e)
    {
        RadRating oRating = (RadRating)sender;
        GridDataItem dataItem = (GridDataItem)oRating.Parent.Parent;
 
        try
        {
            object currentAverageRating = KeywordDT.Rows[dataItem.ItemIndex + RadGridKeyword.CurrentPageIndex * RadGridKeyword.PageSize]["IntCode"];
            decimal currentRating = Convert.ToDecimal(currentAverageRating, NumberFormatInfo.InvariantInfo);
 
            KeywordRelation kr = new KeywordRelation(Getron.Core.Tools.DataTableFieldOperation.ToInt64(currentAverageRating, 0));
            kr.KeyWordWeight = Getron.Core.Tools.DataTableFieldOperation.ToInt32(Decimal.Round((oRating.Value * 10) * 2, 0), kr.KeyWordWeight);
            kr.WithMakerChecker = false;
            kr.Save(this.Page.SystemUser.UserIntCode);
             
            RadGridKeyword.Rebind();
        }
        catch (Exception ex)
        {
            RadGridKeyword.Controls.Add(new LiteralControl("Unable to update Ratings. Reason: " + ex.Message));
        }
    }
 
    [SessionStatePropertyAttribute]
    public DataTable KeywordDT { get; set; }
 
}








5 Answers, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 27 Jun 2012, 01:19 PM
Hello Gökhan,

I tried to reproduce the problem using the sample code you provided, but to no avail. Note that I had to remove parts of the code as it was not possible to run the page without your data source. You can find attached the my test sample. Please compare it with your actual project and let me know what I am missing.

I would suggest checking if somewhere in your code the RadRating property ReadOnly is set to true. Also, you can verify if the problem persists when the RadGrid is not Ajaxified or if you have a JavaScript code on the page that could be altering the default behavior of the rating control.

The online demo RadRating in RadGrid implements functionality similar to yours and it could be used as a reference for properly configuring your project. 

In case you are still having difficulties, please try modifying the attached sample so that the problem is reproducible and describe the changes that you made. This will allow me to inspect the issue on my end and to provide a more to the point answer. A live URL to your page could also be useful for determining the cause of the problem.

Kind regards,
Slav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Gökhan
Top achievements
Rank 1
answered on 27 Jun 2012, 01:48 PM
Hi Slav,

I tried to implement your demo on my page. And I bind your simple datasource, But It didnt work. Result was same. 
Actually I found new situation about this grid. I opened a ticket few weeks ago (http://www.telerik.com/community/forums/aspnet-ajax/grid/cannot-call-method-showfiltermenu-of-null.aspx) . I think this 2 problem point is same. Because this grid full works only when page opened first time. But when page postback ; Rating (NO Action), Filtering(Uncaught TypeError: Cannot call method '_filterNoDelay' of null error), Sorting(WORKING),PAGING(WORKING).


I could not publish sample page for you, privacy rules.. :( But maybe I can send your personel work e-mail address..

Thanks,
Gökhan
0
Slav
Telerik team
answered on 02 Jul 2012, 07:15 AM
Hi Gökhan,

It is possible that the two problems are related. Have you tried the approaches Andrey suggested in the linked forum thread and if you have, what was the result?

Please describe the changes that you made to the sample from my previous response when you implemented it, so that I can reproduce the issue on my end.

All the best,
Slav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Rodrigo
Top achievements
Rank 1
answered on 17 Nov 2012, 05:27 PM
I was having this problem when i used AutoPostBackOnFilter="true" with FilterDelay property.
0
Slav
Telerik team
answered on 21 Nov 2012, 01:13 PM
Hi Rodrigo,

This problem could be related to the one reported in the previously linked forum thread. I would suggest checking the solution provided in this thread and trying it in order to resolve your issue.

If you are still having difficulties, please provide a fully working project and step by step instructions for replicating the problem. Screenshots or video demonstrating the issue could also be useful.

Greetings,
Slav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Rating
Asked by
Gökhan
Top achievements
Rank 1
Answers by
Slav
Telerik team
Gökhan
Top achievements
Rank 1
Rodrigo
Top achievements
Rank 1
Share this question
or