CheckBox Column gets cleared on scroll

16 posts, 0 answers
  1. dootndo2
    dootndo2 avatar
    10 posts
    Member since:
    Dec 2006

    Posted 10 Jan 2008 Link to this post

    We implemented a Check Box column so that the user can select a series of rows to add to a collection and clicks on a button to submit.  When in on click, we check each row for a checked checkbox and add the databounditem to a collection for processsing.  I noticed this evening when I check a few rows and scroll those rows off the screen, the values get cleared when I scroll them back into view.

    I have read in a few posts that you only maintain data in the current view for performance reasons, but is there a way to turn that off?  Or is there another workaround?

    Thanks

    Dennis
  2. Georgi
    Admin
    Georgi avatar
    212 posts

    Posted 11 Jan 2008 Link to this post

    Hello Dennis,

    Thank you for writing.

    Your case requires using an unbound GridViewBooleanColumn. Unfortunately, the current version of RadGridView does not support unbound columns and there is no way to workaround this limitation.

    At the moment, we are refactoring RadGridView. The unbound mode will be available in the new RadGridView once it is released next month.

    If you need further assistance, please contact us.

    Sincerely yours,
    Georgi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Doug Hamilton
    Doug Hamilton avatar
    22 posts
    Member since:
    May 2006

    Posted 07 Apr 2008 Link to this post

    I'm trying to do precisely what the original poster described.  When will a version that will allow mixing of bound and unbound data be released?
  5. Georgi
    Admin
    Georgi avatar
    212 posts

    Posted 09 Apr 2008 Link to this post

    Hi Doug Hamilton,

    You'll find this feature and full support for unbound columns in the new version of RadGridView, which will be a part of our Q1 2008 release, due in mid-April.

    Meanwhile, you could download and try Q1 2008 Beta version: http://www.telerik.com/community/forums/thread/b311D-bceebb.aspx

    Best wishes,

    Georgi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. MikeK
    MikeK avatar
    46 posts
    Member since:
    Oct 2007

    Posted 16 Apr 2008 Link to this post

    I'm having a similar issue but with a databound grid. I have a form with a quantity of databound rows that have only one field as updateable, the checkbox field. At present I'm not committing any changes to the database as the user clicks the checkboxes. My desire is to commit all when they press the commit button.

    As I play with checking and unchecking boxes, about every 10th try will suddenly deselect a weird range of already selected rows. There doesn't appear to be a pattern or reason of why.

    Right now I'm going to try to post these changes to the database and do a rebind on each selection. I wanted to avoid this process, but need to make sure the checkboxes are correct so I have no choice.

    Any idea what's going on?
  7. MikeK
    MikeK avatar
    46 posts
    Member since:
    Oct 2007

    Posted 16 Apr 2008 Link to this post

    Skip that, found the issue. Make sure only the current row is being processed:
        Private Sub RadGrid_CellClick(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles RadGrid.CellClick
            If e.ColumnIndex = 1 Then
                RadGrid.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = Not RadGrid.Rows(e.RowIndex).Cells(e.ColumnIndex).Value
            End If
        End Sub

  8. Michael
    Michael avatar
    8 posts
    Member since:
    Feb 2012

    Posted 11 May 2012 Link to this post

    I am having this problem in v2010.1.10.504

    I have to provide a selectable interface at the click of a button, so I show or hide a value-added checkbox column. (In order to get the clicks to check the checkbox I have to trap CellClick and MouseClick and set the control when those events are triggered, so I got past that awkwardness...)

    However, as soon as the grid scrolls one pixel, all the checks are cleared. I have not found any suggestions or previous conversations which point to a solution. Using any other version of Telerik is not an option at this time.

    Please assist.
  9. Svett
    Admin
    Svett avatar
    728 posts

    Posted 16 May 2012 Link to this post

    Hello Michael,

    I am not able to assist you efficiently with the supplied information. I would kindly ask you to open a support ticket where you can enclose a sample project which demonstrates your scenario. Also, it would be great if you illustrate the exact steps that we should follow in order to replicate this behavior.

    Thank you in advance for your time and cooperation.

    Kind regards,
    Svett
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  10. Michael
    Michael avatar
    8 posts
    Member since:
    Feb 2012

    Posted 16 May 2012 Link to this post

    After I worked up the sample project, found out that I can not submit support tickets due to some poor housekeeping and then pounded my head on the wall some more... I found a solution which is to set a corresponding value in the underlying dataset in the same handlers which handle the clicks, like this.

    It would really be great if there were a way to bind the column for each row to the dataset column/rows, but I couldn't find how that is done in the version we are using, thus a 'brute force' method.

    Two events need to be trapped to detect and visually set the check mark, depending upon whether they click in the checkbox (mouseclick) or if they click in the cell outside of the checkbox (cellclick). The RadGridView is named "mainGrid"

    void mainGrid_MouseClick(object sender, MouseEventArgs e)
    {
        RadElement element = this.mainGrid.ElementTree.GetElementAtPoint(e.Location);
        if (element is RadCheckmark && element.Parent is RadCheckBoxEditorElement)
        {
            GridCheckBoxCellElement checkboxCell = (GridCheckBoxCellElement)((RadCheckBoxEditorElement)element.Parent).Parent;
            checkboxCell.Editor.Value = !(bool)checkboxCell.Editor.Value;
            ((DataView)mainGrid.DataSource).Table.Rows[((Telerik.WinControls.UI.GridCellElement)(checkboxCell)).RowIndex]["Selected"] = checkboxCell.Editor.Value;
        }
    }
     
     
    void mainGrid_CellClick(object sender, GridViewCellEventArgs e)
    {
        GridCheckBoxCellElement cboxElement = (sender as GridCheckBoxCellElement);
     
        if (sender is GridCheckBoxCellElement)
        {
            cboxElement.Editor.Value = !(bool)cboxElement.Editor.Value;
            ((DataView)mainGrid.DataSource).Table.Rows[((Telerik.WinControls.UI.GridCellElement)(cboxElement)).RowIndex]["Selected"] = cboxElement.Editor.Value;
        }
    }

    I can send you the small project (somehow?), just in case you want to see what I was doing for the sake of providing a better solution. :)
  11. Svett
    Admin
    Svett avatar
    728 posts

    Posted 18 May 2012 Link to this post

    Hello Michael,

    I am glad to hear that you found a solution on your own. Nevertheless, I would kindly ask you to provide us with a sample project where the illustrated behavior occurs. RadGridView usually automatically commits the changes from the editors to its underlying data source. Hence, you do not need to perform any further actions. You can open a support ticket where you can attach your project and details about it. This will allow us to handle this case, once we are able to reproduce it.

    Greetings,
    Svett
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  12. Michael
    Michael avatar
    8 posts
    Member since:
    Feb 2012

    Posted 18 May 2012 Link to this post

    As stated in the previous reply, I am unable to submit tickets. Please provide another mechanism to get the sample project to you.

    Thank you,
  13. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 18 May 2012 Link to this post

    Michael, 

    If you're unable to submit a ticket, then you can always copy the code here (using the format code blocks). Forum posts do not have the same priority as support tickets, but this is the next best way I know of to submit code for review. 

    Hope this helps
    Richard
  14. Michael
    Michael avatar
    8 posts
    Member since:
    Feb 2012

    Posted 18 May 2012 Link to this post

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using Telerik.WinControls;
    using Telerik.WinControls.UI;
     
    namespace clearingCheckboxes
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                this.Load += new EventHandler(Form1_Load);
            }
     
            void Form1_Load(object sender, EventArgs e)
            {
                mainGrid.SuspendLayout();
     
                mainGrid.GridElement.BeginUpdate();
     
                mainGrid.MasterGridViewTemplate.AutoGenerateColumns = false;
                mainGrid.MasterGridViewTemplate.AllowAddNewRow = false;
                mainGrid.MasterGridViewTemplate.AllowEditRow = false;
     
                mainGrid.CellClick += new GridViewCellEventHandler(mainGrid_CellClick);
                mainGrid.MouseClick += new MouseEventHandler(mainGrid_MouseClick);
                mainGrid.CellFormatting += new CellFormattingEventHandler(mainGrid_CellFormatting);
     
                // add a checkbox for allowing selecting rows to export
                GridViewCheckBoxColumn cboxcolumn = new GridViewCheckBoxColumn("Selected", "Selected");
                cboxcolumn.VisibleInColumnChooser = cboxcolumn.IsVisible = false;
                mainGrid.MasterGridViewTemplate.Columns.Add(cboxcolumn);
                // add some other columns
                GridViewTextBoxColumn edtcol = new GridViewTextBoxColumn("column1", "column1");
                edtcol.TextAlignment = ContentAlignment.TopLeft;
                edtcol.IsVisible = true;
                mainGrid.MasterGridViewTemplate.Columns.Add(edtcol);
     
                edtcol = new GridViewTextBoxColumn("column2", "column2");
                edtcol.TextAlignment = ContentAlignment.TopLeft;
                edtcol.IsVisible = true;
                mainGrid.MasterGridViewTemplate.Columns.Add(edtcol);
     
                edtcol = new GridViewTextBoxColumn("column3", "column3");
                edtcol.TextAlignment = ContentAlignment.TopLeft;
                edtcol.IsVisible = true;
                mainGrid.MasterGridViewTemplate.Columns.Add(edtcol);
     
                // create a datatable/dataset of data
                DataSet dataSet = new DataSet();
                System.Data.DataTable table = new DataTable("Table");
                // Declare variables for DataColumn and DataRow objects.
                DataColumn column;
                DataRow row;
     
                // Create new DataColumn, set DataType,
                // ColumnName and add to DataTable.   
     
                // whether or not we have a column in the dataset makes no difference, the checkbox clears
                column = new DataColumn();
                column.DataType = System.Type.GetType("System.Boolean");
                column.ColumnName = "Selected";
                // Add the Column to the DataColumnCollection.
                table.Columns.Add(column);
     
                column = new DataColumn();
                column.DataType = System.Type.GetType("System.String");
                column.ColumnName = "column1";
                column.ReadOnly = true;
                column.Unique = true;
                // Add the Column to the DataColumnCollection.
                table.Columns.Add(column);
     
                column = new DataColumn();
                column.DataType = System.Type.GetType("System.String");
                column.ColumnName = "column2";
                column.ReadOnly = true;
                column.Unique = true;
                // Add the Column to the DataColumnCollection.
                table.Columns.Add(column);
     
                column = new DataColumn();
                column.DataType = System.Type.GetType("System.String");
                column.ColumnName = "column3";
                column.ReadOnly = true;
                column.Unique = true;
                // Add the Column to the DataColumnCollection.
                table.Columns.Add(column);
     
                dataSet.Tables.Add(table);
     
                for (int i = 0; i <= 40; i++)
                {
                    row = table.NewRow();
                    row["column1"] = "hello "+ i;
                    row["column2"] = "world " + i;
                    row["column3"] = "foo " + i;
                    try
                    {
                        table.Rows.Add(row);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
     
                mainGrid.DataSource = dataSet.Tables[0].DefaultView;
                mainGrid.ResumeLayout();
                mainGrid.GridElement.EndUpdate();
            }
     
            // trapping out the editor to get value changed demonstrates that ValueChanged does not fire when the checkbox is cleared via a scroll...
            void mainGrid_CellFormatting(object sender, CellFormattingEventArgs e)
            {
                if (sender is GridCheckBoxCellElement)
                {
                    RadCheckBoxEditor editor = (RadCheckBoxEditor)((Telerik.WinControls.UI.GridDataCellElement)(e.CellElement)).Editor;
     
                    if (editor != null)
                    {
                        editor.ValueChanged += new EventHandler(editor_ValueChanged);
                    }
                }
            }
     
            void editor_ValueChanged(object sender, EventArgs e)
            {
                int i = 0;
            }
     
            void mainGrid_MouseClick(object sender, MouseEventArgs e)
            {
                RadElement element = this.mainGrid.ElementTree.GetElementAtPoint(e.Location);
                if (element is RadCheckmark && element.Parent is RadCheckBoxEditorElement)
                {
                    GridCheckBoxCellElement checkboxCell = (GridCheckBoxCellElement)((RadCheckBoxEditorElement)element.Parent).Parent;
                    checkboxCell.Editor.Value = !(bool)checkboxCell.Editor.Value;
                    ((DataView)mainGrid.DataSource).Table.Rows[((Telerik.WinControls.UI.GridCellElement)(checkboxCell)).RowIndex]["Selected"] = checkboxCell.Editor.Value;
                }
            }
     
     
            void mainGrid_CellClick(object sender, GridViewCellEventArgs e)
            {
                GridCheckBoxCellElement cboxElement = (sender as GridCheckBoxCellElement);
     
                if (sender is GridCheckBoxCellElement)
                {
                    cboxElement.Editor.Value = !(bool)cboxElement.Editor.Value;
                    ((DataView)mainGrid.DataSource).Table.Rows[((Telerik.WinControls.UI.GridCellElement)(cboxElement)).RowIndex]["Selected"] = cboxElement.Editor.Value;
                }
            }
     
            private void btnSelect_Click(object sender, EventArgs e)
            {
                mainGrid.Columns["Selected"].IsVisible = true;
            }
        }
    }

  15. Svett
    Admin
    Svett avatar
    728 posts

    Posted 23 May 2012 Link to this post

    Hello Michael,

    Thank you for writing back.

    After I inspected your code, I determined that RadGridView does not allow editing of its values. Could you give us more information what you want to achieve? Why do you try to enable editing when you have explicitly disabled it? If you want to enable only editing of the check box column, you should set the ReadOnly property for the rest of the columns to false.

    Off topic, please note that in order to be able to access the support ticketing system you will need to have a valid license with support subscription, or to be added as Licensed Developer to account with such license. More information regarding this matter can be found in the "Cancelling a Context Menu Click" thread, which you have previously opened (it is available in Your Telerik account). Please bear in mind that your account might be denied support services from Telerik representatives until you enable support for it.

    Regards,
    Svett
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  16. Michael
    Michael avatar
    8 posts
    Member since:
    Feb 2012

    Posted 23 May 2012 Link to this post

    Thanks for your reply. Please note that I created a SAMPLE project for you which is representative of the problem. This is not actual production code. In preparing test data I contrived this example. Please do not get side-tracked, as I see it, with the concept of read-only and the checkbox columns being less than cooperative.

    I find no discernible linkage between your point/question and the issue, please elucidate how you see they are linked; if this is correct, then you should be able set them to read-write and remove my code which handles the checkbox column and it should work?

    Or provide Telerik sanctioned methods of achieving the results (which is, at will, to display a column of checkboxes so users can select line items to export - those checks are then iterated, the corresponding rows then exported).

    Concerning support. I am afraid we lack a certain level of coordination on our side and the only thing we have, as relayed previously to Nikolay, is an invoice number. I inherited this project and was/am not involved in the choosing or purchasing of Telerik controls. I can only assure you that Nikolay verified the invoice. That is as far as I can provide information for you.

    In conclusion, I have worked-around the drawback. Whether or not you can find issues with the Telerik controls is merely academic at this point, I suppose.

    Thank you again.
  17. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 29 May 2012 Link to this post

    Hello Michael,

    Our RadControls can be used in many different scenarios using many different settings. As we are trying to think of what might cause the issue that you describe, you are trying to exclude the possible reasons for this issue getting to the true reason. The question that my colleague Svett has asked is adequate to what you have given as information, given the fact that you are describing that you want to edit the checkboxes while at the same time your code clearly outlines that you are avoiding the editing operation. This controversial information made us confused, so this was the first question to ask in order to clear the path to the real case. I hope that you understand our position. 

    As to your license, as I mentioned in the other thread of yours, the invoice number that you have given is correct. Still, in order to be able to open support tickets in our ticketing system and to get further responses from Telerik representatives, you have to be added as a license developer to the purchase.

    Finally, we are glad to hear that you managed to find a solution for your case. Still, we would again strongly recommend updating to the latest version at your earliest convenience, because since Q1 2010 many issues have been addressed and many new features have been introduced.

    All the best,
    Nikolay
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top
UI for WinForms is Visual Studio 2017 Ready