We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Get the list of SelectedItems, Add New item to Grid, Display Sl No, get edited rows. ReplyClose Incident

Thread ID:

Created:

Updated:

Platform:

Replies:

127066 Oct 24,2016 10:44 AM UTC Oct 25,2016 11:01 AM UTC WPF 1
loading
Tags: SfDataGrid
Varalakshmi
Asked On October 24, 2016 10:44 AM UTC

Hi,

We are using sfDataGrid for one of our Projects, and we are having below issues. Please suggest the solutions for these, We are using WPF - MVVM. 
Note: BlankSheetList is an ObeservableCollection of Type BlankSheet. SelectedBlankSheet is of type BlankSheet : NotificationObject

1. We are using the Selection mode as Extended. We can get the first selected item as below, which gives the first item in the selected list.
 SelectionMode="Extended"
 SelectedItem="{Binding SelectedBlankSheet, Mode=TwoWay}"   
The Question is, how do we get a List of all the items that are selected? 
Documentation says We can use SelectedItems . But that gives this error - "The Property ''SelectedItems" does not have an accessible setter"

2. We want the users to  be able to add more items to the list, on a button click. However when we try the below code, even though the item gets added to  the collection, it doesn't show up on the grid. We want the item to  show up on the grid, as soon as it gets added to  the collection.
View:
 ItemsSource="{Binding BlankSheetList, Mode=TwoWay}"
ViewModel:
BlankSheetList.Add(theBS);

3. How to display the serial number for each of the item in sfDataGrid?

4. How to  get a list of all the edited rows in the grid and mark it with an "*" in one of the column?

Thanks on advance for the help.
Varalakshmi


Srinivasan Vasu [Syncfusion]
Replied On October 25, 2016 11:01 AM UTC

Hi Varalakshmi 
  
Please find the responses for your queries as below,  
  
               Query  
  
                                           
                               Answer  
How do we get a List of all the items that are selected?  
You can get all the SlectedItems in the grid by using SfDataGrid.SelectedItemsproperty but you cannot set the SelectedItems using this property.  
UG Link:  
  
We want the users to  be able to add more items to the list, on a button click  
You can add the Items at run time by using the below code,  
  
<Button  Content="Click"syncfusion:FocusManagerHelper.FocusedElement="True"    
        Command="{BindingPath=DataContext.RowDataCommand,ElementName=sfGrid}"CommandParameter="{Binding}"/>  
  
  
public void ChangeCanExecute(object obj)  
        {  
            this.UserDetails.Add(new UserInfo() { UserId = 12323, ContactNo = "(833) 215-6503", Name = "Peter", Salary = 12123 });  
        }  
  
  
How to display the serial number for each of the item in SfDataGrid?  
We already have a kb for this and please find the link from below,  
  
How to get a list of all the edited rows in the grid and mark it with an "*" in one of the column?  
You can achieve your requirement by using CurrentCellBeginEdit event like below,  
  
this.AssociatedObject.CurrentCellBeginEdit += AssociatedObject_CurrentCellBeginEdit;  
  
List<UserInfo> list = new List<UserInfo>();  
void AssociatedObject_CurrentCellBeginEdit(object sender,CurrentCellBeginEditEventArgs args)  
{  
    var recordIndex =this.AssociatedObject.ResolveToRecordIndex(args.RowColumnIndex.RowIndex);  
    var record = this.AssociatedObject.View.Records[recordIndex].Data asUserInfo;  
  
    if (!list.Contains(record))  
        list.Add(record);  
  
    record.Status = "*";  
}  
  
  
 
  
  
Regards,  
Srinivasan   
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;