Hi,
I am new to XamDataGrid.
Can you please tell me how to create radio button as a XamDataGrid columns.
And also how to fetch the ID (The primary key column binded to the grid) for the radio button selected.
Thanks,
Ritesh
Hi Alex
I Have kind of similar problem, instead I am using CheckBox instead of radio buttons which comes from the template used using CellValuePresenterStlye as Shown in Previous blogs here, Now, How could I get the value of CheckBox along with complete row.
Suppose the CheckBox itself is passed in commandParameter of the checkbox in the template defined.
Now, How can I use GetAncestorFromType and DataRecordPresenter to solve my problem. please explain in bit detail or any other simple alternative to this.
Thanks.
Ritesh,
1) Try setting CellWidth and LabelWidth to 10 or less in the FieldSettings.
2) You can use our helper methods. In this case - Infragistics.Utilities.GetAncestorFromType(...) and get the DataRecordPresenter. The DataRecordPresenter exposes a Record property, which exposes the Cells collection. You can also go for the CellValuePresenter and again the record and cells.
Please let me know if you have any questions on this.
super show :)
I modified the check box column as below.
<igDP:UnboundField Name="Select"> <igDP:UnboundField.Settings> <igDP:FieldSettings> <igDP:FieldSettings.CellValuePresenterStyle> <Style TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <StackPanel> <StackPanel Orientation="Horizontal"> <RadioButton Name="chkSelect" GroupName="grpSelect" HorizontalAlignment="Center" Checked="chkSelect_Checked"/> </StackPanel> </StackPanel> </ControlTemplate> </Setter.Value> </Setter> </Style> </igDP:FieldSettings.CellValuePresenterStyle> </igDP:FieldSettings> </igDP:UnboundField.Settings> </igDP:UnboundField>
i have 2 problems here. :P
1. I am not able to reduce the column width. It is taking the default width. Can you tell me how to do it? I want to reduce it to 10 or even lesser. It tried to reduce it in <igDP:FieldSettings CellWidth="200"> but of no use.
2. How to get the value of a cell for the selected row?
For example when i select(check) the first row(John Smith), i want to ge the department name (Human resources) in RadioButton_Checked event.
I am attaching a sample project with this functionality.
The Radio buttons are are grouped by the department value, so that only one of that group can be checked. You can see that the index of each record in the last field as well as in the Output window when you check one of the Radio buttons. On the bottom you can see the current active record and the selected records.
Let me know if you have any questions on this.
Thanks for the reply Alex.
Can you give me the code snippet for the same?
What i want is ...
1. XamDataGrid with radio button in it.
2. The check changed event on clicking a row radio button. (How to call the event)
3. Fetch the id for the selected row in the check changed event.
The very basic stuff is what i require. I know it sounds wierd. :)