I am using DataGrid (bind to the obeservable collection), one of the column in the datagrid is checkbox, User Requirement is, when user checks checkbox in any row, other row's checkbox should reset to unchecked. means only one checkbox checked at a time.
I tried using INotifyPropertyChanged but no luck, please suggest. Thanks
<igGrid:XamWebGrid x:Name="_dgAppInfo" AutoGenerateColumns="False" ColumnWidth="*" ItemsSource="{Binding AppList}"> <igGrid:XamWebGrid.EditingSettings> <igGrid:EditingSettings AllowEditing="Row" IsEnterKeyEditingEnabled="True" IsF2EditingEnabled="True" IsMouseActionEditingEnabled="SingleClick" IsOnCellActiveEditingEnabled="True" /> </igGrid:XamWebGrid.EditingSettings> <igGrid:XamWebGrid.SelectionSettings> <igGrid:SelectionSettings CellClickAction="SelectRow" RowSelection="Single"></igGrid:SelectionSettings> </igGrid:XamWebGrid.SelectionSettings> <igGrid:XamWebGrid.Columns> <igGrid:TextColumn Key="AppID" HeaderText="ID"/> <igGrid:TextColumn Key="AppName" Width="*" HeaderText="Name"/> <igGrid:CheckBoxColumn Key="AppActive" Width="*" HeaderText="Active"/> </igGrid:XamWebGrid.Columns> </igGrid:XamWebGrid>
Hi,
I'm binding the data of type System.Collections.Generic.List<> to the XamWebGrid. On the click event of cell, I'm displaying the related data in stackpanel for edit. With the Update click on stackpanel I want to refresh the grid - the row - for the respective changes. Will you please help me, hoe can I get this done with INotifyPropertyChanged or is there any other way?
I've done something like this now -
***********************************************************************************************************
void igAddresses_CellClicked(object sender, Infragistics.Silverlight.CellClickedEventArgs e) { SelectedRow = ((XamWebGrid)sender).ActiveCell.Row.Data as Address;
txtEditCompanyAddLine1.Text = SelectedRow.AddLine1.ToString(); txtEditCompanyAddLine2.Text = SelectedRow.AddLine2.ToString(); txtEditCity.Text = SelectedRow.City.ToString(); txtEditState.Text = SelectedRow.State.ToString(); txtEditZip.Text = SelectedRow.Zip.ToString(); } void btnEditUpdate_Click(object sender, RoutedEventArgs e){ // update data in grid int iAddTypeID = 0; iAddTypeID = SelectedRow.AddTypeID; for (int iRowCnt = 0; iRowCnt < lstAddresses.Count; iRowCnt++) { if (iAddTypeID == lstAddresses[iRowCnt].AddTypeID) { lstAddresses[iRowCnt].AddLine1 = txtEditCompanyAddLine1.Text; lstAddresses[iRowCnt].AddLine2 = txtEditCompanyAddLine2.Text; lstAddresses[iRowCnt].Zip = txtEditZip.Text;
lstAddresses[iRowCnt].City = txtEditCity.Text; lstAddresses[iRowCnt].State = txtEditState.Text; lstAddresses[iRowCnt].Country = ((ComboBoxItem)cmbEditCountry.SelectedItem).Content.ToString(); lstAddresses[iRowCnt].CountryCode = Convert.ToInt32(((ComboBoxItem)cmbEditCountry.SelectedItem).Tag); // lstAddresses[iRowCnt].AddTypeID = Convert.ToInt32(((ComboBoxItem)cmbAddType.SelectedItem).Tag); break; } } igAddresses.ItemsSource = null; igAddresses.ItemsSource = lstAddresses;}
Thanks in advance.
Pragati
You'd have to write some custom logic, outside the grid. Specifically, you're going to need to hook up the INotifyPropertyChanged event to every item in your collection. Then keep track of the item that is currently checked. When the NotifyPropertyChanges for that property, you'd change the item that was checked to false.
Hope this helps get you started.
-SteveZ