How can we just clear radgridview

6 posts, 0 answers
  1. andi
    andi avatar
    18 posts
    Member since:
    Oct 2018

    Posted 21 Nov 2018 Link to this post

    Hi All,

    How can we just clear radgridview, clear row, column, relation also on their template ?. Then radgridview being like the first time it loaded when then application run. So we can define columns on it over and over. Instead of using those :

            RadGridView1.DataSource = Nothing
            template.DataSource = Nothing
            template1.DataSource = Nothing

            While Me.RadGridView1.Rows.Count > 0
            Me.RadGridView1.Rows.RemoveAt(Me.RadGridView1.Rows.Count - 1)
            End While

            While Me.RadGridView1.Columns.Count > 0
                RadGridView1.Columns.RemoveAt(Me.RadGridView1.Columns.Count - 1)
            End While

            While template.Rows.Count > 0
            template.Rows.RemoveAt(template.Rows.Count - 1)
            End While

            While Me.RadGridView1.Relations.Count > 0
                Me.RadGridView1.Relations.RemoveAt(Me.RadGridView1.Relations.Count - 1)
            End While

     

    Thanks in advance

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3948 posts

    Posted 22 Nov 2018 Link to this post

    Hello, Andi, 

    Setting the DataSource property to null for the respective template in RadGridView is a suitable approach for clearing the data loaded in the control. If the columns are automatically generated, setting the DataSource property to null, will also clear the columns as well. However, it would be necessary to clear the Relations/Templates collections if you have setup hierarchy. It is just necessary to call the Relations.Clear method.

    I hope this information helps.

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. andi
    andi avatar
    18 posts
    Member since:
    Oct 2018

    Posted 22 Nov 2018 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    RadGridView1.Templates.Clear() need to do on hierarchy isn't it
  4. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3948 posts

    Posted 23 Nov 2018 Link to this post

    Hello, Andi, 

    The MasterTemplate.Templates.Clear method should be called in order to clear the hierarchy levels. The same is valid for the Relations collection as it is noted in my previous post.

    Are you experiencing any difficulties with it?


    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  5. nate
    nate avatar
    2 posts
    Member since:
    Nov 2018

    Posted 28 Nov 2018 Link to this post

    In order to remove a single row from RadGridView, you should simply call the the Removemethod and pass an object of type GridViewDataRowInfo as an argument :  this.radGridView1.Rows.Remove(rowToRemove);

     

  6. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3948 posts

    Posted 29 Nov 2018 Link to this post

    Hello, Nate,    

    The RadGridView.Rows.Remove method allows you to remove row by row. However, this won't clear the columns, the hierarchical templates and relations. It is applicable if you just want to clear the rows.

    I hope this information helps. 

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top