Hi,
We have a grid with one string column and rest all are check box columns.
We are trying to improve the user experience by providing check boxes for selecting / deselecting all in the corresponding column / row headers.
The row header should show the string column value for that row and all other cells will display checkboxes.
selecting/ deselecting a header checkbox for a column does appropriate action for all the rows.
Similarly , selecting/deselecting a checkbox in row header will do appropriate action for all cells in that row.
Getting checkboxes in column headers is quite easy. We need to tweak with some properties of column to get that done.
I am struggling with displaying headers for row. I looked into some samples and made
I could manage the Rowselectors to display a text using DrawFilter but I feel that its not much flexible to include the checkbox in the row selector.
Later I set the style of the identifier column to Button and could display the items in the string column similar to row header.
Now I need to place a checkbox in the same cell to provide a select/deselect all option for the entire row.
I have also tried using CardView for Band but didnt find it much useful.
Can anybody guide me on how to achieve this.
Thanks,
Satish
Hi Satish,
I got a little bit lost in your description.
tsatish said:I could manage the Rowselectors to display a text using DrawFilter but I feel that its not much flexible to include the checkbox in the row selector.
I was with you up to this point.
tsatish said:Later I set the style of the identifier column to Button and could display the items in the string column similar to row header.
I'm not totally clear on what the Identifier column is. Is that the string column? If so... why would you want to set it to Button style? I thought you wanted CheckBoxes, so what does Button have to do with it? Are you trying to make it a toggle button?
The WinGrid doesn't have any built-in functionality for synchronizing the checkboxes in a row with a row header like it does for the columns. But it seems to me that the easiest thing for you to do would to use another checkbox column for this. You could add an unbound column to the grid and set it's DataType to CheckState. This would give you a three-state checkbox column and you could write code in the CellChange event so that when this checkbox is clicked, you synchronize all of the other cells in the same row.
Hi Mike,
Thanks for your reply.
Yes the identifier column is the string column I was talking about.
While exploring different ways to display row headers, I first tried tweaking row selectors using DrawFilter.
Later, as a second option I tried setting the cellStyle of the string column to button to get a row header kind of look and feel.
I will try the approach you have suggested.
Meanwhile, Can you let me know if there is any way that we can set the cellstyle to button and display a checkbox in that to achieve the same style as column header checkboxes.
tsatish said:Meanwhile, Can you let me know if there is any way that we can set the cellstyle to button and display a checkbox in that to achieve the same style as column header checkboxes.
If you set the Style to button, the cells will show a button - not a CheckBox. It seems like what you want is a state button, not a regular button. You could acheive this using an editor - but the problem is that a single cell cannot easily store two different pieces of information - the text and the state of the checkbox/button.
It will be a lot easier to use a separate unbound column as the row header. But if you really want to combine the string column and the checkbox in one column, then there are a couple of ways you could do it.
Both approaches are pretty complicated and which approach you choose depends on exactly what you want.
Does the string column need to be editable by the user?
Do you want it to display as a state button or a string plus a textbox?
Thanks for your inputs. I am going with having an unbound column in the grid for row headers.
Right now I am creating a custom grid control that derives from ultragrid and has this extra ability set (Row and column headers)
We have a set of business validations when checking/unchecking any of the cells in the rows. If the validation fails, we will display a warning dialog to the user.
In normal grid we are handling it in BeforeCellUpdate event. We subscribe to BeforeCellUpdate event and do the validations and show a warning dialog. Based on users choice, we wil either cancel or continue with the change.
In the custom control, I want to handle the row header updates in OnBeforeCellUpdate.(To make it a feature of the custorm control)
Individual cell updates shall be done normally by subscribing to the BeforeCellUpdate event.
Can I use these events like this.
Can you let me know a better way to achieve this.
For the row headers (which are really just cells), I would use OnCellChange. OnBeforeCellUpdate will not be triggered until the user leaves the cell or commits the change in some way. So the user will click on the checkbox and nothing will happen, and then when the tab out of the cell the other cells in the row will be updated. Maybe that's what you want, but it seems like a weird user experience to me.
OnCellChange will be triggered immediately when the user click on the CheckBox. The only caveat is that the Value of the cell won't be updated when OnCellChange fires. So you have to use the Text property of the cell to get the actual on-screen value of the checkbox.
There's no reason why the event should fire unless:
1) You set the state of the header checkbox for the column.
2) The header checkbox is set to synchronize with the column values and you are changing one of the cells values for that column.
In any case, it should be very easy to track this down. Just put a breakpoint inside the event and look at the call stack and you can see exactly what sequence of events caused the event to fire.
It's also very easy to get around - simply don't hook the event until after you bind the grid.
I have almost completed the custom control I was mentioning about.
For row headers, the following article helped me very much
http://es.infragistics.com/community/forums/t/10947.aspx
Apart from the row headers, I had included check boxes in column headers for each column(except for the unbound column) and I am doing synchronization on my own.
Every thing worked fine, until I added the checkbox in header for the unbound column.
The problem I am getting right now is that the events BeforeHeaderCheckBoxStateChanged and AfterHeaderCheckBoxStateChanged events are firing unwantedly at the end of databinding. I have filtered the entry into these events during InitializeRow, Setting row header and setting column header. But still, these events fire only for the Unbound column. This event is not fired for other columns at this stage. I have no clue except that this column is an unbound column.
If I remove the code that adds checkbox to the column header of this unbound column, the events did not fire(obviously)
Can you please help me sort out this issue.