Launching modal form from onupdate callback (Grid)

71 views
Skip to first unread message

Sarbjit

unread,
Sep 9, 2014, 7:24:27 AM9/9/14
to web...@googlegroups.com
I am using the Dialog plugin from http://dev.s-cubism.com/plugin_dialog to display modal dialog form.

My requirement is that whenever the user edits the Grid record, then I should do some validation on the form contents (I'll be using onvalidate callback for my custom form validation).

Once the validation is complete, I want to display the form with some pre-populated fields, if the user accepts this modal form, then I'll run one external script in addition to updation of the grid data. If the user donot submit the form, it should just update the grid record.

Example

This is the example usage shown in the plugin doc.

def index():
    dialog = DIALOG(LOAD(f='inner', ajax=True), title='Test',
                    close_button='close', renderstyle=True)
    return dict(dialog=A('show dialog', _href='#',
                         _onclick='%s;return false;' %dialog.show()))
                        
def inner():
    return DIV('OK!')

What I'm trying is :- (In onupdate callback)

def myonupdate(form):
    print 'update!'
    dialog1 = DIALOG(LOAD(f='inner', ajax=True), title='Test',
                    close_button='close', renderstyle=True)
    dialog1.show()

Problem :-


It doesn't opens the modal form, while in the example on clicking button, a modal form does appears.

Is there any way, I can make this modal form to appear on editing the grid record or I can open a conformer dialog when the user is updating the grid such that I can run the additional external process if the answer is yes.

Sarbjit

unread,
Sep 9, 2014, 9:31:12 AM9/9/14
to
I tried linking the modal dialog on "_onclick" event of Submit button, it does brings up the modal dialog when the Edit mode is used on grid record. However with this change, it just opens the modal dialog and closing it, takes back to edit form and the changes are not updated in db.

That's why I wanted to launch this dialog from onupdate/onvalidation callback such that my form submission will be completed and user just had to close this modal dialog.

Derek

unread,
Sep 9, 2014, 3:49:09 PM9/9/14
to web...@googlegroups.com
Yes, you cannot do that, you are mixing javascript (LOAD) with Python. You have to make the changes to the view, not the controller.

Sarbjit

unread,
Sep 10, 2014, 5:10:52 AM9/10/14
to
I tried the following such that when the user clicks on Submit button from the Grid edit form, it would open the dialog.

grid.element(_type='submit')['_onclick']='%s;return true' %dialog1.show()

So my modal dialog does comes up, but then it closes and my grid is seen again. Still struggling to get it fixed.

Can I some how with javascript wait to return back unless the modal dialog is closed.
Reply all
Reply to author
Forward
0 new messages