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

SfDataGrid SelectedItems - how to clear or set?

Thread ID:

Created:

Updated:

Platform:

Replies:

119232 May 27,2015 09:27 AM UTC Jan 30,2017 01:03 PM UTC Xamarin.Android 3
loading
Tags: SfDataGrid
Michel Uiterwijk
Asked On May 27, 2015 09:27 AM UTC

Hi all,

I am still experimenting with the SfDataGrid and would like to know how to adjust the SelectedItems in the grid, while the property SelectedItems itself is readonly. Could not find any code samples for it...

Does someone have a magical tip for this?

Kind regards,
Michel.


Harikrishnan N [Syncfusion]
Replied On May 29, 2015 05:50 AM UTC

Hi Michel,

Thank you for contacting Syncfusion support.

We have analyzed your requirement and we have added support for adjusting SelectedItems. This will be included in our upcoming Service pack release which is scheduled to release by the end of this week.


You can achieve your requirement when the SelectionMode is Multiple as in the below code snippet.

SfDataGrid sfGrid;

ViewModel viewModel;

protected override void OnCreate(Bundle bundle)

{

    base.OnCreate(bundle);

    SetContentView(Resource.Layout.Main);

    sfGrid = new SfDataGrid(BaseContext);

    viewModel = new ViewModel();

    sfGrid.ItemsSource = viewModel.OrdersInfo;

    sfGrid.SelectionMode = SelectionMode.Multiple;

    Button selectedItems = new Button(this.BaseContext);

    selectedItems.Text = "Set Selection";

    selectedItems.Click += SetSelection_Click;

    LinearLayout layout = (LinearLayout)FindViewById(Resource.Id.Linear);

    layout.AddView(selectedItems);

    layout.AddView(sfGrid);

}


void SetSelection_Click(object sender, EventArgs e)

{

    //For adding an item in SelectedItems

    sfGrid.SelectedItems.Add(viewModel.OrdersInfo[0]);

    //For removing an item in SelectedItems

    sfGrid.SelectedItems.RemoveAt(0);

    //For clearing the Selection

    sfGrid.SelectedItems.Clear();
}




Please let us know if you require further assistance.

Regards,
Harikrishnan

Steve
Replied On January 27, 2017 03:18 AM UTC

try
mySFGrid.SelectionController.SelectedRows.Clear();

Divakar Subramaniam [Syncfusion]
Replied On January 30, 2017 01:03 PM UTC

Hi Steve, 
  
Thanks for the update. You can achieve your requirement using the mentioned code (SelectedRows.Clear()) also. Please let us know if you need any other assistance from us. 
  
Regards, 
Divakar. 


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

;