Hi,
I need some functionality to be able to show some related data in a single row in the data grid. For that I planned to show a data grid in a cell of the grid.
For example below are my classes:
class A
{
public string A1;
public string A2;
public string A3;
public List<B> A4;
}
class B
public string B1;
public string B2;
public string B3;
class A with fields A1,A2,A3 & A4 ; another class B with fields B1, B2 & B3.
B1 is the primary key in B with A1 as its foreign key.
I need to show the data for each object of A in a single row including data of field A4 (type is B). So, in the grid I am expecting columns A1,A2,A3 & A4. I planned A4 to show as a combo and that combo will have a grid to show all the data for that field.
1. Is that possible to show a combo for a field in data grid?
2. Is that possible to attach a data grid to that combo box so that to display all the fields of that complex fields in the sub grid?
3. After achieving the above two points I have to ensure that user can select that combo box and change the pair of selected rows from the sub-grid. Also, the user should be able to select the complete row. So, is that possible to have row as well as cell selection (for some specific cells)?
PS: I am using Ultra Win Grid in a windows application.
Thanks in Advance for the help.
Hello Nitin,
There are different approaches to solve this task depending of your requirements. I made small sample for you with one possible approach. Could you please take a look at the attached smple for more details and let me know if you have any question.
Regards
Here is the sample
Thanks Georgi,
This is exactly what I need. However, even after applying the similar changes to my code, I am not getting the combo box.
In my case I can select the complete row only and the cells are not editable. Is there any way by which I can select the complete row and the specific cells with combo box in the same grid?
Regards,
Nitin Jain
Also, are there any other approaches? As I have to provide a way to select the pair of records from the sub grid, and show that pair or related key/text in the main grid column
Nitin Jain said: As I have to provide a way to select the pair of records from the sub grid, and show that pair or related key/text in the main grid column
Yes, it is possible. For example you could handle ultraGrid1_AfterCellListCloseUp() event:
private void ultraGrid1_AfterCellListCloseUp(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e) { ultraGrid1.ActiveRow.Cells["selectedChildId"].Value = ultraCombo1.SelectedRow.Cells["Id"].Value; ultraGrid1.ActiveRow.Cells["SelectedChildParentId"].Value = ultraCombo1.SelectedRow.Cells["ParentId"].Value; }
Please take a look at the new sample with desired behavior and let me know if you have any questions.
Thanks Georgi for all the useful info. This will definitely help me out.
I also found one thing that in our code base we are assigning Cell.Activation = Activation.NoEdit for each cell, that is preventing to show the combo box.
I added a check and assigned Activation.Edit for these complex columns only. But, I need to prevent user to enter any thing manually in the columns itself.
Any ideas on this?
Did you try my suggestion with
ultraGrid1.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.RowSelect; instead of Cell.Activation = Activation.NoEdit
Could you please take my last sample (UltraGridWithComboAndClassObjectHierarchy (3).zip) and modify it to reproduce your scenario and revert it back to me. I`ll be glad to research to for you.
Let me know if you have any questions.
Hi Boris,
That is awesome. This is exactly what I need from decorative point of view.
Thanks for the reply.
You could achieve this using the following code in the 'BeforeCellListDropdown' event:
ultraCombo1.DisplayLayout.Bands[0].Columns[1].Hidden = true; ultraCombo1.DisplayLayout.Bands[0].Columns[0].Header.Caption = "Custom";
Please feel free to let me know if a question about our tool set comes up on your mind.
Is there any way by which we can show certain columns and hide some when popping up the sub-grid in combo-box?
Also, Is it possible to change the display name of the columns in sub-grid?
Thanks Boris,
This is exactly what I need. Actually by mistake (or by lack of knowledge) I set Cell's Style property to DropDown, which I guess was incorrect in both the manners.
But now after setting up columns style property I am getting a non-editable drop down control, that I needed.
Many Thanks to both of you for all the help provided.
Could you please review the sample attached to this post and see if it meets your requirements.Please feel free to let me know if I misunderstood you or if you have any other questions.