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

radGridView, Checkbox & Combobox Issue

6 Answers 307 Views
GridView
This is a migrated thread and some comments may be shown as answers.
jerry
Top achievements
Rank 1
jerry asked on 20 Mar 2009, 03:12 PM
I'm currently using the demo controls to develop my application.

I have 3 combobox the first is populated on load and the next one is populated based on the first and the third based on the selection in the second drop down.

One the user selects the first 2 combobox selections I query my oracle db and set the datasource of my first grid to that data table.
If the user changes the 3rd combbox then I filter the data in my datatable and rebind.  My problem on the rebinding is the issue of my checkbox column.  The checkboxes do not clear out when I rebind.  I've tried deleting the column and readding it but then my data doesn't bind all I see is the checkbox column.

What is suppose to happen when a user selects a checkbox is the second datagrid is populated based on their selection.  They can check multiple rows.  The second data grid will also have a checkbox column that I will use to  generate a report.

My main problem is when I have to clear my grids and rebind the checkbox column doesn't seem to work correctly.

Please any help would be greatly apprciated.

This is my code to remove and readd the checkbox column to my first grid. Which isn't working.
GridViewCheckBoxColumn chkCol = radGridView1.MasterGridViewTemplate.Columns["Selected"as GridViewCheckBoxColumn;  
if (chkCol != null)  
{  
radGridView1.MasterGridViewTemplate.Columns.Remove(chkCol);  
GridViewCheckBoxColumn chkCol = new GridViewCheckBoxColumn();                   
chkCol.DataType = typeof(int);  
chkCol.UniqueName = "Selected";  
chkCol.FieldName = "Selected";  
chkCol.HeaderText = "";            
radGridView1.MasterGridViewTemplate.Columns.Add(chkCol);  
}  

Anything that can point me in the right direction would be greatly appreciated.  I'm on a time constraint and am trying to verify I can do all this with the telerik controls. 

6 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 20 Mar 2009, 06:00 PM
Hello jerry,

Thank you for your interest in our controls.

The code that you have sent us does not compile, because you have used the same identifier twice, but it helped in reproducing the issue. RadGridView caches its columns based on the UniqueName property and hence when you add a column using the same UniqueName the values are taken from the cache. Unfortunately, there is no easy work-around for it. I can suggest only this one:

int i = 0; 
        private void radButton1_Click(object sender, EventArgs e) 
        { 
            GridViewCheckBoxColumn chkCol = radGridView1.MasterGridViewTemplate.Columns["col"+i.ToString()] as GridViewCheckBoxColumn; 
                
            if (chkCol != null)   
            { 
                radGridView1.MasterGridViewTemplate.Columns.Remove(chkCol);    
                GridViewCheckBoxColumn newchkCol = new GridViewCheckBoxColumn();                    
                newchkCol.DataType = typeof(int);   
                newchkCol.UniqueName = "col"+(++i).ToString();     
                newchkCol.HeaderText = "A";             
                radGridView1.MasterGridViewTemplate.Columns.Add(newchkCol); 
                this.radGridView1.Columns.Move(this.radGridView1.Columns.Count - 1, 0); 
            }   
        } 
 
Please note that you should use this work-around with caution, because columns are never disposed and hence your form will consume more and more memory every time you add a column.

Do not hesitate to write me back if you have further questions. 

Greetings,
Nick
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
jerry
Top achievements
Rank 1
answered on 20 Mar 2009, 06:20 PM
Nick,
Thank you so much for responding. 

So what is the best way to handle my situation with having a checkbox column in my grid?
This is going to part of an exe that is going onto a shared drive where many people can use it so memory is a big issue.

Based on my scenario what Telerik Controls would work the best?  Is there a control I'm not seeing that could help?

Do you have any example projects on your site that show how the checkbox column in a datagrid works?

Thanks agian for your patience and time. 

Jerry
0
Nick
Telerik team
answered on 23 Mar 2009, 12:19 PM
Hello jerry,

Thank you for your interest in our controls. I think that there is no other control that can substitute RadGridView in your scenario. On the plus side, we have re-considered the issue's importance to our customers and we are going to provide a fix in our next service pack (expected within a month). Thank you for your understanding. Do not hesitate to write me back if you have other questions. 

Sincerely yours,
Nick
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
jerry
Top achievements
Rank 1
answered on 23 Mar 2009, 01:42 PM
Nick,
thanks for the reply.  On the main post I didn't mean to have two columns with the same name that was intentional at all.
I think I found a work around what I do now is i'm keeping a list of ids. When I user checks or unchecks a row I update the list and then filter my dataset then rebind to the datagridview.  So far it seems to work.  Lets hope it stays that way.  LOL


Thanks again
Jerry
0
jerry
Top achievements
Rank 1
answered on 23 Mar 2009, 07:31 PM
Nick,
Based on the code I posted I get the column of checkboxes.  My problem with them now is that I have filtering on and if the users selected the checkbox in the heading it pretty much crashes.  When I tried to handle it my datagridview loses it's data and says there are zero rows..

What is the best way to handle the filter checkbox for an entire checkbox column?


Thank You
jerry
0
Nick
Telerik team
answered on 25 Mar 2009, 07:05 PM
Hi jerry,

Thank you for contacting us back.

I am not sure that I can reproduce this exception with the information you have provided so far. The issue (columns not being removed from the cache when they are removed from the Columns collection) will be fixed in our next service pack. I hope that this will fix all your problems and you will not need partial work-arrounds.

Please do not hesitate to write me back if you have other questions. 
 

Greetings,
Nick
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
jerry
Top achievements
Rank 1
Answers by
Nick
Telerik team
jerry
Top achievements
Rank 1
Share this question
or