Adding New row

8 posts, 0 answers
  1. Naveen T
    Naveen T avatar
    30 posts
    Member since:
    Jun 2012

    Posted 17 Mar 2010 Link to this post

    Hi,

    I am adding New Row to QueryableCollectionView at runtime, its adding at end of the last row( rad grid),but i need to add new row to the First page-first row.


    Regards,
    Nav
  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 19 Mar 2010 Link to this post

    Hi nav kum,

    You have to insert the new item at index zero in the underlying collection, i.e. the collection that you have passed to the constructor of QueryableCollectionView. You can do it like this:

    using System.Windows;
    using Telerik.Windows.Controls;
    using Telerik.Windows.Data;
    using Telerik.Windows.Controls.GridView;
    using System.Windows.Controls;
    using System.Collections.ObjectModel;
    using System;
     
    namespace TicketID_291840_ColumnIsEnabled
    {
        /// <summary>
        /// Interaction logic for Window1.xaml
        /// </summary>
        public partial class Window1 : Window
        {
            ObservableCollection<Club> clubs = Club.GetClubs();
             
            public Window1()
            {
                InitializeComponent();
     
                var qcv = new QueryableCollectionView(this.clubs);
                this.clubsGrid.ItemsSource = qcv;
     
            }
     
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                this.clubs.Insert(0, new Club("NewClub", DateTime.Now, 50000));
            }
        }
    }

    I have attached a sample project. I hope this helps.

    Best wishes,
    Ross
    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.
  3. DevCraft banner
  4. Jonx
    Jonx avatar
    258 posts
    Member since:
    Jul 2012

    Posted 26 Apr 2011 Link to this post

    Hello Ross,
    I have the same problem.
    I'm using RIA Services.
    And I insert my row with the "Insert new row" feature.
    Once I press return, the row moves from the first row to the last one...
    I would like the inserted rows be added on top of the grid and get their correct place only once I submitted the changes.
    I asking this because I have more rows in my grid the visible on the screen.
    That means that when I insert a row, once I press return, it looks like the rows disapears when it is moved to the end...
    How can I change the way the grid inserts the new rows?
    Thanks a lot in advance,
    John.
  5. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 27 Apr 2011 Link to this post

    Hello John,

    You can always set ShowInsertRow to true and have a pinned row shown at the top of the grid. That way you will not have to worry about item positioning. 


    Greetings,
    Milan
    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
  6. Jonx
    Jonx avatar
    258 posts
    Member since:
    Jul 2012

    Posted 27 Apr 2011 Link to this post

    Hello Milan,
    That is what I have. I use the Insert Row at the top to insert my new rows.
    The problem I have is that once inserted (press return), the rows are added at the end of the collections when I want them to be inserted at the beginning. Also note that I'm talking about what I want before having submitted my changes. After that, I understand that the rows are sorted...
    Do you see what I mean? Sorry for the bad explanation...
    John.
  7. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 28 Apr 2011 Link to this post

    Hi John,

    I afraid that new items are automatically added at the end of the source collection. RadGridView does not influence this mechanism in any way - i.e, this is not caused by RadGridView. Once way to deal with this is to have some custom field which will be used for sorting. Based on that field the new items will be placed on top of the grid. 

    For example, this could be an integer field which has value of 1 for all old items and value of 0 for all new items. Once you add a SortDescriptor for this custom field the data will be sorted accordingly. 


    Greetings,
    Milan
    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
  8. Jonx
    Jonx avatar
    258 posts
    Member since:
    Jul 2012

    Posted 28 Apr 2011 Link to this post

    Will this work even before I do submit the changes?

    Maybe another solution would be to scroll the inserted row into view...
    Can this be done? Would you mind showing how to do?
    To scroll the newly inserted row into view...

    Thank you for your help,
    John.
  9. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 03 May 2011 Link to this post

    Hi John,

    There should be no problem to do this. You can try the following:

    public MainPage()
    {
        InitializeComponent();
      
        this.playersGrid.RowEditEnded += new EventHandler<GridViewRowEditEndedEventArgs>(playersGrid_RowEditEnded);
    }
      
    void playersGrid_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
    {
        if (e.EditOperationType == Telerik.Windows.Controls.GridView.GridViewEditOperationType.Insert)
            this.playersGrid.ScrollIntoViewAsync(e.EditedItem, null);
    }


    Kind regards,
    Milan
    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
Back to Top
DevCraft banner