开发者

jqgrid - how do not show edit form if condition not met

开发者 https://www.devze.com 2023-02-02 09:27 出处:网络
Another jqgrid question. On my page i got a select drop down. If nothing is selecting and the user click to add record, the edit form should no popup. I can\'t seems to find how to do this in google.

Another jqgrid question. On my page i got a select drop down. If nothing is selecting and the user click to add record, the edit form should no popup. I can't seems to find how to do this in google. Here is what I have:

    afterShowForm:function(formid) {
        if ( ($('#listbox').val()) == "" ) {
            alert('Please select an option.');
            $('#'+formid, form).hide();
            return开发者_运维百科 false;
        }
    }

The above code is not working. It actually got error - form is not defined. Should I be using afterShowForm or is there a more proper way to do it.

Thanks.


Ok guys. I found a 'solution' but I am not sure if that is the best way to do it (I think it is not :) ) but it gets the job done.

Instead of using formid pass in through the function, I have view source and get the id of the edit form id. For my case the id is #editmodmy_table. So to hide the form from showing, I just use jquery to do it.

$('#editmodmy_table').hide();

Other than that, we have to get rid of the overlay that is attached to the edit form modal as well. Hiding the edit form don't hide the overlay automatically. So we have to do this:

$('.jqmOverlay').hide();

Hope this helps someone.

Please post a better solution to this if any. Thanks.


The error in this code means that the variable 'form' is not defined.

If I understand this correctly that variable is not needed. To find the form and hide it you could try something like this instead:

$('form#'+formid).hide();
0

精彩评论

暂无评论...
验证码 换一张
取 消