Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
537 views
in Technique[技术] by (71.8m points)

jquery - jqGrid Reposition Delete Confirmation Box

I am currently using jqGrid with the navGrid, del set to true. Problem is when a user clicks on delete, it pops up a confirmation box in the upper left hand of the grid. Since we are already scrolled down to the very bottom, which i have a large height, the user has to go all the way to the top to confirm. Is there any way to move the position of this? A manual offset is just fine, but ideally i want to dock it to the bottom left, as apposed to top left.

Thanks in advance

(If this is a dupe I am sorry. I tried just posting it but it gave me some weird error and is not showing in my history so assumed it did not post.)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I find is not a dupe. On the opposite I find it good so +1 from me.

The jqGrid use internally the method viewModal ($.jgrid.viewModal) which shows the most dialogs. The method has toTop parameter, but and delGridRow and editGridRow dosn't use it and it will be set to toTop:true. So the Add, Edit and Delete dialogs will be displayed always to the top of the grid which can be inside of inviable area.

To fix the problem you can define the afterShowForm event handle which change the dialog position. For example

$("#list").jqGrid('navGrid','#pager', {}, {}, {},
                  {
                      afterShowForm: function($form) {
                          var dialog = $form.closest('div.ui-jqdialog'),
                              selRowId = myGrid.jqGrid('getGridParam', 'selrow'),
                              selRowCoordinates = $('#'+selRowId).offset();
                          dialog.offset(selRowCoordinates);
                      }
                  });

In the example the dialog will be placed over the selected row. The code can be improved for the case when the selected row in the last row and the bottom part of the dialog is outside of the window. Nevertheless the above implementation seems me better as the default one because the user see the dialog exactly over the row which he want to delete and he can move the dialog so that it will be full visible.

You can test the suggested movement of the Delete dialog on the live demo.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...