how can i show checkbox column

4 posts, 1 answers
  1. Jeongmin
    Jeongmin avatar
    7 posts
    Member since:
    Feb 2013

    Posted 07 Aug 2013 Link to this post

    Hi. I have a problem. 

    I have a DataTable ;
    DataTable  IsChecked column datatype is string(DB type is varchar. I use oracle db) and Data is Y OR N

    I want show this data in RadGridview with checkbox column .

    I coded below. but ToggleStateConverter any method not call.
    Wha's wrong? Help me.

    I buy DevCraft Complete product. I want your reply  24 h response.
     


    (User defined class and attach Attribute Sample is well work.)
    ex)
                this.radGridView1.AutoGenerateColumns = true;

                this.radGridView1.DataSource = dsResult.Tables[0];   
                var checkBoxColumn = new GridViewCheckBoxColumn();
                checkBoxColumn.HeaderText = " IsChecked ";
                checkBoxColumn.Name = " IsChecked ";
                checkBoxColumn.Width = 100;
                checkBoxColumn.IsVisible = true;
                checkBoxColumn.DataType = typeof(string);
                checkBoxColumn.DataTypeConverter = new ToggleStateConverter();

                this.rndGridView1.Columns[0] = checkBoxColumn;








  2. Ivan Petrov
    Admin
    Ivan Petrov avatar
    717 posts

    Posted 12 Aug 2013 Link to this post

    Hello Jeongmin,

    Thank you for writing.

    You cannot assign a new instance to a column that has already been added to RadGridView. You should hide the autogenerated column and insert the new column on the index where you want to see it.
    this.radGridView1.AutoGenerateColumns = true;
    this.radGridView1.DataSource = dsResult.Tables[0];  
    var checkBoxColumn = new GridViewCheckBoxColumn();
    checkBoxColumn.HeaderText = " IsChecked ";
    checkBoxColumn.FieldName= " IsChecked ";
    checkBoxColumn.Name = " IsChecked ";
    checkBoxColumn.Width = 100;
    checkBoxColumn.IsVisible = true;
    checkBoxColumn.DataType = typeof(string);
    checkBoxColumn.DataTypeConverter = new ToggleStateConverter();
     
    this.rndGridView1.Columns[0].IsVisible = false;
    this.rndGridView1.Columns.Insert(0, checkBoxColumn);

    There is initialization logic that is performed when a column is added to RadGridView. This is why you have to add the column and cannot assign it. You should also set the FieldName property of the column so it will know from which property of the data source it will get the data.

    Please have in mind that support threads are handled according to the license type and time of posting, so if it is an urgent issue, we suggest that you use a support ticket, which would be handled before a forum thread.

    I hope this will be useful. Should you have further questions, I would be glad to help.

    Regards,
    Ivan Petrov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. Jeongmin
    Jeongmin avatar
    7 posts
    Member since:
    Feb 2013

    Posted 13 Aug 2013 Link to this post

    Thank you for your answer. But Your code sample does not work properly.
    CheckBox column is Added . but When Data is 'Y'  CheckBox Column not Check.
    Still  ToggleStateConverter any method not called. 
    I inserted CheckBox column ( not assigned) .
    Do you give the complete code sample ?

       DataSet dsColumn = this.GetColumnList();

       this.gridColumn.AutoGenerateColumns = true;
       this.gridColumn.DataSource = dsColumn.Tables[0];

       var checkBoxColumn = new GridViewCheckBoxColumn
                    {
                        HeaderText = " GRID_VISIBLE_YN ",
                        FieldName = " GRID_VISIBLE_YN ",
                        Name = " GRID_VISIBLE_YN ",
                        Width = 100,
                        IsVisible = true,
                        DataType = typeof (string),
                        DataTypeConverter = new ToggleStateConverter()
                    };

       this.gridColumn.Columns.Insert(0, checkBoxColumn);


  4. Answer
    Ivan Petrov
    Admin
    Ivan Petrov avatar
    717 posts

    Posted 15 Aug 2013 Link to this post

    Hi Jeongmin,

    Thank you for writing back.

    I have attached an example where I have copied the converter from our help article. The only difference is that I modified it so it would work with strings rather than characters. I bind the grid view to a DataTable with a string column and show the values form that column in the grid check box column.

    One thing I noticed in your code is that you have an empty spaces around the field name of the column:
    " GRID_VISIBLE_YN ". This would make the field name invalid and will cause the column to not work correctly. I would suggest you remove this spaces and try your project again.

    I hope this helps. Do not hesitate to write back with further questions.

    Regards,
    Ivan Petrov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top