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

Selected cells in RadGrid - off by one column

3 Answers 98 Views
Grid
This is a migrated thread and some comments may be shown as answers.
charles
Top achievements
Rank 1
charles asked on 06 Jan 2016, 03:49 PM
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title></title>
    <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
        </Scripts>
    </telerik:RadScriptManager>
    <script type="text/javascript">
        //Put your JavaScript code here.
    </script>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    </telerik:RadAjaxManager>
    <div>
 
    </div>
    <telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0" Skin="WebBlue">
<ExportSettings>
<Pdf>
<PageHeader>
<LeftCell Text=""></LeftCell>
 
<MiddleCell Text=""></MiddleCell>
 
<RightCell Text=""></RightCell>
</PageHeader>
 
<PageFooter>
<LeftCell Text=""></LeftCell>
 
<MiddleCell Text=""></MiddleCell>
 
<RightCell Text=""></RightCell>
</PageFooter>
</Pdf>
</ExportSettings>
 
        <ClientSettings AllowKeyboardNavigation="True">
            <Selecting CellSelectionMode="MultiCell" />
            <Scrolling AllowScroll="True" UseStaticHeaders="True" />
        </ClientSettings>
 
<MasterTableView ShowFooter="False">
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
 
 
<ExpandCollapseColumn Visible="True"
        FilterControlAltText="Filter ExpandColumn column" Created="True">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
 
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
</EditFormSettings>
 
<BatchEditingSettings EditType="Cell"></BatchEditingSettings>
 
<PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
</MasterTableView>
 
<PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
 
        <SelectedItemStyle BackColor="#FF9999" />
 
<FilterMenu EnableImageSprites="False"></FilterMenu>
    </telerik:RadGrid>
    <telerik:RadButton ID="RadButton1" runat="server" Text="Highlight any cells in the grid above then click this button.  Do that twice, and notice how it is off by one column."
        onclick="RadButton1_Click" Height="112px" Width="1263px" Font-Size="Large">
    </telerik:RadButton>
    <p>
         </p>
    </form>
</body>
</html>

 

 

 

 

 

 

 

 

//the following is code-behind (default.aspx.cs) 
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;
 
public partial class Default : System.Web.UI.Page
{
         
    protected void Page_Load(object sender, EventArgs e)
    {
        //populate RadGrid with test table data
        if (IsPostBack == false)
        {
            RadGrid1.DataSource = GenerateTestTable( );
            RadGrid1.DataBind();
        }
    }
 
    
    protected void RadButton1_Click(object sender, EventArgs e)
    {
        //do something with selected/hilighted cells - WHY IS IT OFF BY ONE COLUMN?!?!?!?!?!?!?
        foreach (GridTableCell  item in RadGrid1.SelectedCells )
        {
            item.Text = "Hello!";
            item.BackColor = System.Drawing.Color.Aquamarine;
        }
    }
 
 
    static DataTable GenerateTestTable()
    {
        // create DataTable columns
        DataTable dt = new DataTable();
        for (int i = 0; i < 8; i++) { dt.Columns.Add("Column_" + i.ToString(), typeof(int)); }
 
        // create DataTable rows
        DataRow dr = null;
        for (int row = 0; row < 8; row++)
        {
            dr = dt.NewRow();
            for (int col = 0; col < 8; col++) { dr[col] = col +row*8; }
            dt.Rows.Add(dr);
        }
        
        return dt;
    }
 
 
}

 

 

// why is it off by one column?!?!?!?!?



3 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 08 Jan 2016, 02:10 PM
Hello Charles,

I tried to replicate the behavior you describe, however I was not able to. I made a short video of what I am observing. Check it out here.

Let me know if I am missing something.

On a side note, please ensure that you are using the latest version of the controls. The current release is version 2015.3.1111.

Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
charles
Top achievements
Rank 1
answered on 08 Jan 2016, 05:55 PM
Hi Viktor -- I will study your video soon, but are you saying there may have been a bug in the older version?  I may have to convince management to upgrade the whole business application.
0
Konstantin Dikov
Telerik team
answered on 13 Jan 2016, 09:18 AM
Hi Charles,

The tests that Viktor have performed were made with the latest version, but that does not necessary mean that there is a bug with older version (although that it is possible). That was just a note that you should consider when watching the video.


Kind Regards,
Konstantin Dikov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
charles
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
charles
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or