I have a XamDataGrid with checkboxes in one of the columns.
<igDP:UnboundField Name="unbAddToRefresher"
Label="Add To Refresher" Width="150">
<igDP:UnboundField.Settings>
<igDP:FieldSettings>
<igDP:FieldSettings.CellValuePresenterStyle>
<Style TargetType="{x:Type igDP:CellValuePresenter}" >
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<CheckBox Name="chkChooseForRefresher" HorizontalAlignment="Center" VerticalAlignment="Center">
</CheckBox>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</igDP:FieldSettings.CellValuePresenterStyle>
</igDP:FieldSettings>
</igDP:UnboundField.Settings>
</igDP:UnboundField>
When I click a button on the page, I would like to loop through all rows and save a field value from this row if the checkbox is checked.
In ASP.Net, I would do this on the button's click event handler -
For index As Integer = 0 To GridView1.Rows.Count - 1
Dim cb As CheckBox = CType(GridView1.Rows(index).FindControl("chkChooseMe"), CheckBox)
If cb.Checked Then ...
For WPF with Infragistics, I'm not sure what to do. I tried this, but it didn't work -
For index As Integer = 0 To XamDataGrid1.Records.Count - 1
Dim cb As CheckBox = CType(dgrRefresher6166.Records(index).FindControl("chkCreateDocumentsRowLevel"), CheckBox)
This give the error - 'FindControl' is not a member of 'Infragistics.Windows.DataPresenter.Record'
How can I read the values of the checkboxes?
Thanks!
Hello Howord,
You can use a code like this:
For Each record As var In GridView1.Records
Dim age = TryCast(TryCast(record, DataRecord).DataItem, Person).Age
Next
where Person can be replaced with your custom class.
Hope this helps you.
I'm lost. Are we still using GetDescendantFromType? And how?
Could you write this out?
Also, what articles explain how to learn this stuff?
Thanks.
Hello Howard,
DataRecordPreenters are available only for the viewable Records, since there is a virtualization in the XamDataGrid. You can loop all DataItems by casting each Record to DataRecord and then cast its DataItem Property to your custom class.
I'm sorry to bug you, but on the 35th row, "DataRecordPresenter.FromRecord(item)" is Nothing
and the line "Dim cb As CheckBox = ...." gives an error.
Is that because the XamDataGrid is lazy loading?
My grid may have thousands of rows.
Thank you.
Is this the best way? Is there a more efficient way?
Is there a way to use the item in the loop you showed me?
Is there a better way to get the key field value?
localClientID = CType(XamDataGrid1.Records(iRowCount), DataRecord).DataItem("client_id")