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

Adding new row

1 Answer 136 Views
VirtualGrid
This is a migrated thread and some comments may be shown as answers.
Dineesh
Top achievements
Rank 1
Dineesh asked on 14 Nov 2018, 06:30 AM

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.

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 14 Nov 2018, 09:09 AM
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.
Tags
VirtualGrid
Asked by
Dineesh
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or