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,
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
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
I get another solution, its getting saved to grid, but not refreshing the grid immediately. The changes are getting reflected on next visit to page. The code is like -
void btnEditUpdate_Click(object sender, RoutedEventArgs e) { int iAddTypeID = 0; iAddTypeID = SelectedRow.AddTypeID; for (int iRowCnt = 0; iRowCnt < igAddresses.Rows.Count; iRowCnt++) { if (iAddTypeID == ((Address)igAddresses.Rows[iRowCnt].Data).AddTypeID) { ((Address)igAddresses.Rows[iRowCnt].Data).AddLine1 = txtEditCompanyAddLine1.Text;
--------
((Address)igAddresses.Rows[iRowCnt].Data).CountryCode = Convert.ToInt32(((ComboBoxItem)cmbEditCountry.SelectedItem).Tag); break; } igAddresses.UpdateLayout(); } }
How the changes will reflect immediately on this click?
Thanks,
Pragati.
Sorry, one correction -
igAddresses.UpdateLayout();
should be before the
break;
Still no change in output.
If possible, the best way to do this is to ensure that the objects in your List implement INotifyPropertyChanged. The grid will atomatically listen for the property change notifications and updated itself immediately when the object properties are updated.
Devin
It should work with List<T>, but like I said, you need to make sure the objects in your List<T> implement the INotifyPropertyChanged interface.
Thanks for reply. So, I've to take the ObservableCollection or it can be worked with System.Collection.Generic.List<>, if yes then please reply with example. You can send me code on pragati.dukale@revalanalytics.com
Please, help.