This is a migrated thread and some comments may be shown as answers.

[Solved] Set Selection on based on Row Index and swapping

1 Answer 96 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Prakash
Top achievements
Rank 1
Prakash asked on 05 Oct 2010, 04:31 PM
Hi 
  
#1. I can able to select the single row by passing the row index..
Selection mode is Extended only.
  
public void setSelectedItemByIndex(int index)
{
this.SelectedItem = Items[index]; 
}
  
How can i select multiple rows
  
like this.selecteditems = ?
  
#2. I need to swap rows by passing index .. for example giving sourceindex and targetindex.
  
I did like this. but doesnt work. can u give a sample.
  
public long RowSwapping(int SourceIndex, int TargetIndex)
{
long lResult = 0;
IList lstsource = this.ItemsSource as IList;
object objSource = lstsource[SourceIndex];
object objTarget = lstsource[TargetIndex];
lstsource.Remove(objSource);
lstsource.Remove(objTarget);
lstsource.Insert(SourceIndex, objTarget);
lstsource.Insert(TargetIndex, objSource);
this.ItemsSource = lstsource;
return lResult;
}

1 Answer, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 06 Oct 2010, 07:05 AM
Hi,

 You can Add in SelectedItems. Can post more info what exactly didn't worked for your second question? If the grid ItemsSource is not INotifyCollectionChange you need to call Rebind() for the grid manually. 

Kind regards,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Prakash
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or