Adding new row

2 posts, 1 answers
  1. Dineesh
    Dineesh avatar
    2 posts
    Member since:
    Apr 2010

    Posted 14 Nov 2018 Link to this post

    Hi,

    I am binding data from a datatable to the VirtualGrid but currently there is no data in it, so I would like to have a blank row appear in the grid which will allow the user to enter new rows.

    Currently if there are no data then nothing is showing in the grid, only when some data is there "Click here to add a new row" appears.

    AllowAddNewRow is true.

     

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

    Posted 14 Nov 2018 Link to this post

    Hello, Dineesh, 

    In order to show the new row ("Click here to add a new row"), it is necessary to have RowCount > 0. Thus, you will be able to show the column headers, the rest of the system rows like the new and filtering rows and one data row. 

    public RadForm1()
    {
        InitializeComponent();
     
        this.radVirtualGrid1.RowCount = 1;
        this.radVirtualGrid1.ColumnCount = 5;
        this.radVirtualGrid1.CellValueNeeded += radVirtualGrid1_CellValueNeeded;
    }
     
    private void radVirtualGrid1_CellValueNeeded(object sender, Telerik.WinControls.UI.VirtualGridCellValueNeededEventArgs e)
    {
        if (e.RowIndex == -1 && e.ColumnIndex > -1)
        {
            e.Value = "Column" + e.ColumnIndex;
        }
    }

    Please refer to the following help article demonstrating how to handle add, delete and update rows in RadVirtualGrid: https://docs.telerik.com/devtools/winforms/virtualgrid/working-with-data/handle-add-delete-update-of-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