Switch to edit mode after insert

5 posts, 0 answers
  1. Petr
    Petr avatar
    31 posts
    Member since:
    Jul 2015

    Posted 23 Jan 2017 Link to this post

    Dear all,

    I use Radgrid with popup window. I want to implement specific scenario. My item has relations to different tables and I can add/modify them only when item is created (otherwise I don't have primary key). My idea is: when I insert new item I want to save it and automatically open the same item in edit mode. It means user can continue to create additional relations and it is not necessary to find new item in grid and start edit mode.

    Can you help me if it is possible and how to implement it?

    Thank you,

    Petr

  2. Petr
    Petr avatar
    31 posts
    Member since:
    Jul 2015

    Posted 23 Jan 2017 Link to this post

    In the meantime I found another post which is helpful for me. During insert I store key values for inserted record. Then during preRender method I find correct row and I set GridItem.Edit = true and call RadGrid.Rebind().

    It shows update dialog with my inserted values, but it looks there is still missing some initialization. I see that command "Edit" is not invoked. When I click Update button then dialog is closed, but grid is lost and nothing is updated. Command "Update" is not invoked too.

    Maybe rebind method must be call later or any other initialization must be called. Do you have any idea what is wrong?

    Thanks

  3. Petr
    Petr avatar
    31 posts
    Member since:
    Jul 2015

    Posted 25 Jan 2017 Link to this post

    I solved the problem. At the end I only set selected new record in grid and I register new startup script which start edit for selected item. 

    function openEditWindow() {
        var masterTable = $find($('[id$="RadGrid1"]').attr('id')).get_masterTableView();
        var editItems = masterTable.get_selectedItems();
        if (editItems.length > 0)
            window.setTimeout(function () {
                masterTable.editItem(editItems[0].get_element());
            }, 0);
    }

     

    It looks as the best solution for me.

  4. Eyup
    Admin
    Eyup avatar
    3841 posts

    Posted 26 Jan 2017 Link to this post

    Hi Petr,

    I'm glad you've found a viable solution for your specific scenario.
    You can also achieve this requirement by determining the position of the newly inserted row, as explained in the following post:
    http://www.telerik.com/forums/select-inserted-updated-row-after-performing-command#UqPp6075pUO9rOJsy-RmIw

    Regards,
    Eyup
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  5. Petr
    Petr avatar
    31 posts
    Member since:
    Jul 2015

    Posted 26 Jan 2017 Link to this post

    I don't find this post, but I already implemented something like that. I also use SQL query to find correct row index. I saw that using 2 rebinds is not workable for my grid which contains over 7500 rows on 75 pages.

    Thanks,

    Petr

Back to Top