Question #1
When adding a checkbox column to a gridview and when I turn on the filter option of the grid there is a checkbox that shows up as part of the filter. How can I turn that into a select all checkbox instead of filtering on it? Is there a better alternative to doing this?
Question #2
How come when I add a checkbox to my gridview before filling the gridview with data it just shows the checkbox and it doesn't look right/good is there a way to just have a clear grid or at least make it look better?
Thank You
When adding a checkbox column to a gridview and when I turn on the filter option of the grid there is a checkbox that shows up as part of the filter. How can I turn that into a select all checkbox instead of filtering on it? Is there a better alternative to doing this?
Question #2
How come when I add a checkbox to my gridview before filling the gridview with data it just shows the checkbox and it doesn't look right/good is there a way to just have a clear grid or at least make it look better?
Thank You
16 Answers, 1 is accepted
0
gerbrand
Top achievements
Rank 2
answered on 23 Apr 2009, 02:46 PM
Hi Jerry,
For you first question I think you need to check out this post in the knowledge base
Should help you.
Second question I have no idea.
For you first question I think you need to check out this post in the knowledge base
Should help you.
Second question I have no idea.
0
Gerbrand, thank you for pointing this out. You are faster than me :)
Jerry, to your second question: Could you please describe in more detail the expected appearance in this case. I will be glad to help you further.
All the best,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Jerry, to your second question: Could you please describe in more detail the expected appearance in this case. I will be glad to help you further.
All the best,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
jerry
Top achievements
Rank 1
answered on 23 Apr 2009, 03:44 PM
Thanks fellas for the quick help.
Jack,
when I load my windows form in the load event I add a checkbox column to two different gridviews. The grids don't populate till after the form loads and the user selects different values in drop downs. While the grids are empty I have just a single checkbox showing in both grids just sitting there. I had to disable the filter option for that column so the user doesn't click it and have the app crash. I'm just trying to find a way to hide it until the data fills.
Thanks again i'm going to go work on question 1. Thanks
Jerry
Jack,
when I load my windows form in the load event I add a checkbox column to two different gridviews. The grids don't populate till after the form loads and the user selects different values in drop downs. While the grids are empty I have just a single checkbox showing in both grids just sitting there. I had to disable the filter option for that column so the user doesn't click it and have the app crash. I'm just trying to find a way to hide it until the data fills.
Thanks again i'm going to go work on question 1. Thanks
Jerry
0
Hi Jerry,
Maybe the easiest way is to set the DataSource and add columns when there is a data. If this is not possible, you can hide all system rows. Set the EnableFiltering, ShowColumnHeaders and AllowAddNewRow to false and enable them after loading the data. Here is an example:
I hope this helps. Should you have any other questions, don't hesitate to ask.
All the best,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Maybe the easiest way is to set the DataSource and add columns when there is a data. If this is not possible, you can hide all system rows. Set the EnableFiltering, ShowColumnHeaders and AllowAddNewRow to false and enable them after loading the data. Here is an example:
this.radGridView1.MasterGridViewTemplate.EnableFiltering = false; |
this.radGridView1.MasterGridViewTemplate.ShowColumnHeaders = false; |
this.radGridView1.MasterGridViewTemplate.AllowAddNewRow = false; |
// ... |
this.radGridView1.MasterGridViewTemplate.EnableFiltering = true; |
this.radGridView1.MasterGridViewTemplate.ShowColumnHeaders = true; |
this.radGridView1.MasterGridViewTemplate.AllowAddNewRow = true; |
I hope this helps. Should you have any other questions, don't hesitate to ask.
All the best,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
jerry
Top achievements
Rank 1
answered on 24 Apr 2009, 03:36 PM
Jack,
Thank you so much. Your post gave me and idea to just hide the column until it needs to be displayed.
Thank you
Thank you so much. Your post gave me and idea to just hide the column until it needs to be displayed.
Thank you
0
Jerry, I am glad to hear that. If you have any other questions, feel free to write us.
Best wishes,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Best wishes,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
jerry
Top achievements
Rank 1
answered on 28 Apr 2009, 07:07 PM
Jack,
I went through the steps that gerbrand posted the link too and I'm still having an issue. Following those steps puts a checkbox in the header. I still have a checkbox in the filter section. How can I remove the checkbox from the filter section? What I have now is 2 checkboxes on top of each other 1 in the header 1 in the filter and it looks very odd. How can I remove the filter one?
I went through the steps that gerbrand posted the link too and I'm still having an issue. Following those steps puts a checkbox in the header. I still have a checkbox in the filter section. How can I remove the checkbox from the filter section? What I have now is 2 checkboxes on top of each other 1 in the header 1 in the filter and it looks very odd. How can I remove the filter one?
0
Hi jerry,
Please handle the ViewCellFormatting event to hide the checkbox inside a filter cell. Here is a sample:
If you need further assistance, I will be glad to help.
Sincerely yours,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Please handle the ViewCellFormatting event to hide the checkbox inside a filter cell. Here is a sample:
void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e) |
{ |
if (e.CellElement.RowInfo is GridViewFilteringRowInfo && e.CellElement.ColumnInfo.HeaderText == "Option1") |
{ |
e.CellElement.Children[0].Visibility = ElementVisibility.Collapsed; |
} |
} |
If you need further assistance, I will be glad to help.
Sincerely yours,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
jerry
Top achievements
Rank 1
answered on 01 May 2009, 12:32 PM
Jack,
Thank you for the code. I'm having one other issue with this check all. When each checkbox is checked the
When I check the checkboxes manually this works correctly but with the select all the this.GVTables.ActiveEditor is null.
How come it is null?
I need data from each row to store in lists to generate reports. Is there a different way to get the column values I need with this event?
Here is my code for pulling data from a column with my ValueChanged event.
Thank You
Jerry
Thank you for the code. I'm having one other issue with this check all. When each checkbox is checked the
ValueChanged event for that grid fires. Within that event I have this piece of code to check to make sure it's a checkbox that is being changed
if (this.GVVariables.ActiveEditor is RadCheckBoxEditor) |
When I check the checkboxes manually this works correctly but with the select all the this.GVTables.ActiveEditor is null.
How come it is null?
I need data from each row to store in lists to generate reports. Is there a different way to get the column values I need with this event?
Here is my code for pulling data from a column with my ValueChanged event.
string sID = GVVariables.Rows[this.GVVariables.CurrentCell.RowIndex].Cells[1].Value.ToString(); |
Thank You
Jerry
0
Hi Jerry,
We need some more time to review this case. Please, expect a reply shortly.
Sincerely yours,
Deyan
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
We need some more time to review this case. Please, expect a reply shortly.
Sincerely yours,
Deyan
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
jerry
Top achievements
Rank 1
answered on 06 May 2009, 01:14 PM
Deyan,
no problem thanks for the help.
Jerry
no problem thanks for the help.
Jerry
0
Hello Jerry,
The checkbox inside the header cell is not part from the editors system of RadGridView. Because of this the ActiveEditor property is null. You can get the desired checkbox values by iterating over the grid rows. Here is a sample:
It would be better to use the following syntax when accessing the checkbox value inside ValueChanged event:
I hope this helps. If you have more questions, don't hesitate to ask.
Sincerely yours,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
The checkbox inside the header cell is not part from the editors system of RadGridView. Because of this the ActiveEditor property is null. You can get the desired checkbox values by iterating over the grid rows. Here is a sample:
foreach (GridViewDataRowInfo row in GVVariables.Rows) |
{ |
string value = row.Cells[1].Value.ToString(); |
// ... |
} |
It would be better to use the following syntax when accessing the checkbox value inside ValueChanged event:
this.GVVariables.CurrentRow.Cells[1].Value.ToString(); |
I hope this helps. If you have more questions, don't hesitate to ask.
Sincerely yours,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
jerry
Top achievements
Rank 1
answered on 11 May 2009, 02:14 PM
Jack,
I have two grids and one fills based on the checking of rows in the first grid.
So everytime a row in the first grid is checked I have to query a DB and return the results but then I have to go through the rows and check the ones that were checked already. When I do this code to check the specific row
this.GVVariables.CurrentRow.Cells[1].Value.ToString();
I get nothing. How can I make sure I have access to that row i'm checking?
Thank You
Jerry
I have two grids and one fills based on the checking of rows in the first grid.
So everytime a row in the first grid is checked I have to query a DB and return the results but then I have to go through the rows and check the ones that were checked already. When I do this code to check the specific row
GVVariables.Rows[i].Cells[0].Value = 1;
the valuechanged event for this grid fires and when I do the
if
(this.GVVariables.ActiveEditor is RadCheckBoxEditor)
or
this.GVVariables.CurrentRow.Cells[1].Value.ToString();
I get nothing. How can I make sure I have access to that row i'm checking?
Thank You
Jerry
0
Hello Jerry,
Thank you for staying with us.
When using the UI to change the cell value there is an ActiveEditor associated with that cell. However, when using the Value property, the ActiveEditor is null. I am not sure if I understand correctly your last question. Please send a sample application and describe the desired behavior in more details. I will be glad to help you further.
I am looking forward to your reply.
Sincerely yours,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Thank you for staying with us.
When using the UI to change the cell value there is an ActiveEditor associated with that cell. However, when using the Value property, the ActiveEditor is null. I am not sure if I understand correctly your last question. Please send a sample application and describe the desired behavior in more details. I will be glad to help you further.
I am looking forward to your reply.
Sincerely yours,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
jerry
Top achievements
Rank 1
answered on 11 May 2009, 03:36 PM
Jack,
I can't send a sample app it would take me too long to make one. I will try and describe it better.
I have two grids. We can call them gridTable and gridCol.
When I user checks a row within gridTable I query a DB and list all the columns for the selected table in gridCol.
The user can select as many tables are he wants and gridCol will populate all the columns. Both grids have a checkbox column because the user will select which columns he wants to use to generate a report. Where my issue is happening is when the user unchecks a row within gridTable. I have a list that holds the ids of the tables and columns that were checked. When a user unchecks a table I must remove all the rows from gridCol for the unchecked table.
Since I have to do a query to get back all the columns for the checked rows for gridTable I clear our gridCol then repopulate then I cycle through and programically check all the rows within gridCol that were checked before the user unchecked a row in gridTable. When I do this the valuechange event fires this is where i'm losing the active editor. It's when I programically set the checked rows back to being checked after gridCol is re-populated. Does this make more sense?
Thanks again for your help
Jerry
I can't send a sample app it would take me too long to make one. I will try and describe it better.
I have two grids. We can call them gridTable and gridCol.
When I user checks a row within gridTable I query a DB and list all the columns for the selected table in gridCol.
The user can select as many tables are he wants and gridCol will populate all the columns. Both grids have a checkbox column because the user will select which columns he wants to use to generate a report. Where my issue is happening is when the user unchecks a row within gridTable. I have a list that holds the ids of the tables and columns that were checked. When a user unchecks a table I must remove all the rows from gridCol for the unchecked table.
Since I have to do a query to get back all the columns for the checked rows for gridTable I clear our gridCol then repopulate then I cycle through and programically check all the rows within gridCol that were checked before the user unchecked a row in gridTable. When I do this the valuechange event fires this is where i'm losing the active editor. It's when I programically set the checked rows back to being checked after gridCol is re-populated. Does this make more sense?
Thanks again for your help
Jerry
0
Hi jerry,
Thank you for this clarification.
I think we are getting closer to resolving this.
The ValueChanged event is fired when a cell in RadGridView changes its value. When this happens through code (e.g when setting directly the Value property), there is no ActiveEditor and the sender argument contains a GridViewCellInfo class that represents the changed cell. However, when using the UI the sender argument contains the visual cell element and the ActiveEditor contains RadCheckBoxEditor. The actual cell value is contained in the editor in this case. So, you should check the ActiveEditor.Value property. Here is a sample:
I hope this helps. If you have further questions, please don't hesitate to ask.
Kind regards,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Thank you for this clarification.
I think we are getting closer to resolving this.
The ValueChanged event is fired when a cell in RadGridView changes its value. When this happens through code (e.g when setting directly the Value property), there is no ActiveEditor and the sender argument contains a GridViewCellInfo class that represents the changed cell. However, when using the UI the sender argument contains the visual cell element and the ActiveEditor contains RadCheckBoxEditor. The actual cell value is contained in the editor in this case. So, you should check the ActiveEditor.Value property. Here is a sample:
void radGridView1_ValueChanged(object sender, EventArgs e) |
{ |
GridViewCellInfo cellInfo = sender as GridViewCellInfo; |
if (cellInfo != null) |
{ |
if (cellInfo.ColumnInfo.FieldName == "Option1") |
{ |
int count = 0; |
foreach (GridViewDataRowInfo row in this.radGridView1.Rows) |
{ |
if ((bool)row.Cells["Option1"].Value && row != this.radGridView1.CurrentRow) |
{ |
count++; |
} |
} |
} |
} |
else if (this.radGridView1.ActiveEditor is RadCheckBoxEditor) |
{ |
int count = 0; |
foreach (GridViewDataRowInfo row in this.radGridView1.Rows) |
{ |
if ((bool)row.Cells["Option1"].Value && row != this.radGridView1.CurrentRow) |
{ |
count++; |
} |
} |
if ((bool)this.radGridView1.ActiveEditor.Value) |
{ |
count++; |
} |
} |
} |
I hope this helps. If you have further questions, please don't hesitate to ask.
Kind regards,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.