开发者

jqgrid jquery set a new css class for a errors in dialog box

For checking server side validation errors, I am using "afterSubmit" property of jqGRid.

afterSubmit: checkForErrors

And my checkForErrors is something like this:

function checkForErrors(response,postdata){
    var success = true;
    var message = ""
    var json = eval('(' + response.responseText + ')');
    if(json.errors.length>0) {
        success = false;
        for(i=0; i < json.errors.length; i++) {
            message开发者_如何学JAVA += json.errors[i] + '<br/>';
        }
    }
    var new_id = null;
    return [success,message,new_id];
}

The only thing i need to fix is change the default error class/style used by jqgrid (ie. ui-state-error), to my custom css class. How can i do that.

Thanks!


Try this:

function checkForErrors(response,postdata){
    var success = true;
    var message = ""
    var json = eval('(' + response.responseText + ')');
    if(json.errors.length>0) {
        success = false;
        for(i=0; i < json.errors.length; i++) {
            message += json.errors[i] + '<br/>';
        }
    }
    var new_id = null;

    //Here pass the right class name instead of ".dialog" which you are using in your code
   $(".dialog").find(".ui-state-error").removeClass("ui-state-error").addClass("newClass");

    return [success,message,new_id];
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜