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

GridRatingColumn not triggering batch edit mode

4 Answers 85 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 2
Chris asked on 11 Jul 2013, 04:37 PM
Hi,
I have a grid that is using the batch edit mode and for all of the other non rating columns everything works correctly. Clicking the cell puts it into edit mode, and the changes are saved. I have one column that is a GridRatingColumn. I have it set to allow rating in view mode but this does not seem to make a difference to the outcome, which is that clicking the rating cell or the rating control does not put that cell into edit mode.

I have tried fumbling around with some client side code, but there are no sensible examples on your site just part of a single page. I can;pt get this to work.

Do you have a way around this please?

Thanks

Chris


4 Answers, 1 is accepted

Sort by
0
Antonio Stoilkov
Telerik team
answered on 16 Jul 2013, 06:30 AM
Hello Chris,

I have created a sample project showing the described behavior working correctly on my side. Additionally, I have created a video showing the rating column successfully enters edit mode.

In order to further investigate the problem you could modify the provided project in order to show the unwanted behavior and upload the project in a new formal ticket.

Regards,
Antonio Stoilkov
Telerik
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 the blog feed now.
0
Chris
Top achievements
Rank 2
answered on 16 Jul 2013, 02:39 PM
Hi Antonio,

thanks for your sample, I can get the rating control work in batch mode but it is still behaving inconsistently with the other column types, I can't post a zip of the files I have modified but I will post the code below. I have added notes to further explain my issue.

The biggest problem is that you have to click outside of the rating controls bounds to get edit mode active, but numeric and bound columns you can click anywhere. Also there is no obvious change in the presentation of the control to indicate that edit mode has begun, again this is inconsistent with other columns types.

The natural action for a user will be to click the rating control to make a change and currently this does not trigged the edit mode. I hope that this had made things a bit clearer.

Thanks

Chris

Modified sample code:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GridBatchEditingGridRatingColumn.aspx.cs" Inherits="GridBatchEditingGridRatingColumn" %>
 
<!DOCTYPE html>
 
<head runat="server">
    <title>
    </title>
    <style>
        .RadRating {
            background-color: red;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <p>
                The behaviour is inconsistent between the rating column and the other column types. Batch mode can be entered by clicking on the value to be changed.
                With the 'original rating' column you have to click <b>OUTSIDE</b> of the ratings bounds to enter edit mode, at this point there is no indication that your are in edit mode.
                unlike the other controls. Also in the Rating in View column, changing the value doe not trigger batch mode.
            </p>
            <p>
                Ideally, I would like to be able to use AllowRatingInViewMode='True' and just click on the rating which would register as a batch change (red tag appears, etc).
                The next preferred method would be when using AllowRatingInViewMode='False' when I click on the rating control this should go into edit mode and it should be obvious that edit mode has been entered.
            </p>
            <telerik:RadScriptManager runat="server"></telerik:RadScriptManager>
            <telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource" AutoGenerateColumns="false"
                             EnableEmbeddedBaseStylesheet="True" EnableEmbeddedSkins="True" Skin="Web20">
                <MasterTableView EditMode="Batch">
                    <Columns>
                        <telerik:GridRatingColumn DataField="Rating" HeaderText="Original Rating" ItemCount="15">
                            <HeaderStyle Width="320px"></HeaderStyle>
                        </telerik:GridRatingColumn>
                        <telerik:GridNumericColumn DataField="Rating" HeaderText="Numeric"></telerik:GridNumericColumn>
                        <telerik:GridBoundColumn DataField="Comment" HeaderText="Numeric"></telerik:GridBoundColumn>
                        <telerik:GridRatingColumn DataField="Rating" HeaderText="Rating In View" AllowRatingInViewMode="True" ItemCount="15">
                            <HeaderStyle Width="320px"></HeaderStyle>
                        </telerik:GridRatingColumn>
                    </Columns>
                </MasterTableView>
            </telerik:RadGrid>
        </div>
    </form>
</body>
</html>

Codebehind:

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
public partial class GridBatchEditingGridRatingColumn : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
    protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        DataTable table = new DataTable();
        table.Columns.Add("Rating", typeof(int));
        table.Columns.Add("Comment", typeof(string));
        table.Rows.Add(1,"Biff");
        table.Rows.Add(4,"Blam");
        table.Rows.Add(2,"Whump");
        this.RadGrid1.DataSource = table;
    }
}


0
Accepted
Antonio Stoilkov
Telerik team
answered on 17 Jul 2013, 06:48 AM
Hello Chris,

The described behavior is caused from the fact RadRating does not bubble its events and the grid could not capture that the RadRating have been clicked. In order to resolve your issue you could subscribe to RadGrid RowCreated client-side event and on RadRating click call openCellForEdit as shown below.
function RowCreated(sender, args)
{
    var element = $telerik.findElement(args.get_gridDataItem().get_element(), "Rating");
 
    $addHandler(element.children[0], "click", function(e)
    {
        $find("<%= RadGrid1.ClientID %>").get_batchEditingManager().openCellForEdit(e.target);
    });
}

Note that you could use the rgBatchCurrent class name to highlight the currently edited cell. The rgBatchCurrent is placed on the cell that is currently in edit mode.
.rgBatchCurrent {
    background: red;
}

Additionally, I can ensure you I have notified our dev team to consider the support and implementation for setting AllowRatingInViewMode="true" on the GridRatingColumn.

Regards,
Antonio Stoilkov
Telerik
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 the blog feed now.
0
Chris
Top achievements
Rank 2
answered on 17 Jul 2013, 10:34 AM
Hi Antonio,
this is just what I was after. Thank you very much. It might be worth considering this example for the documentation as I think it is quite a common scenario and the current documentation of the batch edit functionality is not really very good.

Thanks again.

Chris
Tags
Grid
Asked by
Chris
Top achievements
Rank 2
Answers by
Antonio Stoilkov
Telerik team
Chris
Top achievements
Rank 2
Share this question
or