Need To Always Show Insert Row With Detail/Child Grid

4 posts, 0 answers
  1. Alex
    Alex avatar
    3 posts
    Member since:
    Oct 2016

    Posted 13 Oct Link to this post

    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?

  2. Alex
    Alex avatar
    3 posts
    Member since:
    Oct 2016

    Posted 13 Oct in reply to Alex Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Alex
    Alex avatar
    3 posts
    Member since:
    Oct 2016

    Posted 17 Oct Link to this post

    Any thoughts?
  5. Eyup
    Admin
    Eyup avatar
    3008 posts

    Posted 18 Oct Link to this post

    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.
Back to Top