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

Need To Always Show Insert Row With Detail/Child Grid

3 Answers 11 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 13 Oct 2016, 03:17 PM

I have a grid with a single hierarchical child grid that the user may expand. I have the load mode set to "Client" and the edit mode set to "InPlace".

I want there to always be an insert row for the user to add new rows with if they wish. I have accomplished this with the master grid view (parent grid) with this function:

protected void radGrid1_PreRender(object sender, System.EventArgs e)
{
  if (!radGrid1.MasterTableView.IsItemInserted)
    radGrid1.MasterTableView.InsertItem();
}

 

This will cause there to always be an insert row.

However, with the child grid in client mode, there is no callback between expand and collapse for the child grids.

I've tried this with no success:

protected void radGrid1_PreRender(object sender, System.EventArgs e)
{
  if (!radGrid1.MasterTableView.IsItemInserted)
    radGrid1.MasterTableView.InsertItem();
  if (!rgPieces.MasterTableView.DetailTables[0].IsItemInserted)
    rgPieces.MasterTableView.DetailTables[0].InsertItem();
}

 

What am I supposed to do here?

3 Answers, 1 is accepted

Sort by
0
Alex
Top achievements
Rank 1
answered on 13 Oct 2016, 04:02 PM
Thats radGrid1 not rgPieces in the second example. I can't edit my post for some reason which is causing me a non-zero amount of frustration.
0
Alex
Top achievements
Rank 1
answered on 17 Oct 2016, 01:28 PM
Any thoughts?
0
Eyup
Telerik team
answered on 18 Oct 2016, 08:04 AM
Hello Alex,

You can try to use the DetailTableDataBind event handler and set e.DetailTableView.IsItemInserted to True. Alternatively, you can traverse the inner tables manually and set the aforementioned property, but probably it would be too late in the page life cycle:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/how-to/hierarchy/hiding-the-expand-collapse-images-when-no-records

Here is an example:
protected void RadGrid1_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
{
    ...
 
    e.DetailTableView.IsItemInserted = true;
}

I hope this will prove helpful.

Regards,
Eyup
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Grid
Asked by
Alex
Top achievements
Rank 1
Answers by
Alex
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or