QueryableCollectionView+RadGridView+RadDataPager Autonavigation on Page of Item

4 posts, 1 answers
  1. papuasy
    papuasy avatar
    2 posts
    Member since:
    Jul 2011

    Posted 19 Oct 2011 Link to this post

    Hello!

    I have QueryableCollectionView in my view model and i bind it to RadGridView and RadDataPager. When i use MoveCurrentTo() to set current item it work if item on the current page, but if item is not on the current page it is not works.

    There is XAML of test project:
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
     
        <telerik:RadGridView Grid.Row="0" ItemsSource="{Binding Persons}"/>
         
        <telerik:RadDataPager Grid.Row="1" Source="{Binding Persons}"/>
    </Grid>

    There is code for test project:
    public class Person
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }
     
    public class ViewModel
    {
        QueryableCollectionView _Persons;
        public QueryableCollectionView Persons
        {
            get
            {
                if (_Persons == null)
                {
                    _Persons = new QueryableCollectionView(GetPersons());
                    _Persons.PageSize = 20;
     
                    Person person = (_Persons.SourceCollection as List<Person>).FirstOrDefault(p => p.Id == 50);
                    if (person != null)
                        _Persons.MoveCurrentTo(person);
                }
     
                return _Persons;
            }
        }
     
        List<Person> GetPersons()
        {
            List<Person> res = new List<Person>();
            for (int i = 1; i < 100; i++)
                res.Add(new Person() { Id = i, Name = "Name " + i });
     
            return res;
        }
    }

    Is there simple solutions to automatically set current page on page that contains necessary item?

    Thank you.
  2. Answer
    Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 21 Oct 2011 Link to this post

    Hi Papuasy,

     Indeed currency will no affect paging in any way. You need to calculate the page index based on item index and move to the respective page index. 

    Best wishes,
    Vlad
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. papuasy
    papuasy avatar
    2 posts
    Member since:
    Jul 2011

    Posted 21 Oct 2011 Link to this post

    Thank you for reply.

    Is any recomended way to get items count after filtering and sorting is applied, but paging is not applied?
    I think it necessary for calculate page index...

    Thank you.
  4. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 24 Oct 2011 Link to this post

    Hello Papuasy,

     You can use ItemCount to achieve your goal. 

    Regards,
    Vlad
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top