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

Switch to edit mode after insert

4 Answers 62 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Petr
Top achievements
Rank 1
Iron
Petr asked on 23 Jan 2017, 10:24 AM

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

4 Answers, 1 is accepted

Sort by
0
Petr
Top achievements
Rank 1
Iron
answered on 23 Jan 2017, 04:47 PM

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

0
Petr
Top achievements
Rank 1
Iron
answered on 25 Jan 2017, 09:01 AM

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.

0
Eyup
Telerik team
answered on 26 Jan 2017, 09:21 AM
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.
0
Petr
Top achievements
Rank 1
Iron
answered on 26 Jan 2017, 09:33 AM

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

Tags
Grid
Asked by
Petr
Top achievements
Rank 1
Iron
Answers by
Petr
Top achievements
Rank 1
Iron
Eyup
Telerik team
Share this question
or