有时,我们给jqgrid绑定的远端数据获取失败,此时,需要把错误信息反馈给用户展示,如何实现?

可通过jqgrid的 loadError 来处理错误数据的返回。详细如下:

    $("#jqGrid").jqGrid({
url: 'TbQueryList', loadError:
function (xhr, status, error) { var start = xhr.responseText.indexOf("<title>"); var end = xhr.responseText.indexOf("</title>"); abp.message.error(xhr.responseText.substring(start+7, end), "错误信息"); } });

以上错误的正确返回还需要一个前提:url 端的 TbQueryList 方法能拦截错误信息,并通过throw 统一抛出错误信息。

举例如下:

            try
            {
                result = _reportAppService.ExcuteReportSql(code, rows, page, queryParams, sidx, sord, ref err);
                if(err.IsError)
                {
                    throw new Exception(err.Message);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
View Code

相关文章:

  • 2022-12-23
  • 2021-10-16
  • 2021-12-02
  • 2021-11-02
  • 2021-11-28
  • 2021-12-06
  • 2022-01-14
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-13
  • 2021-05-18
  • 2022-12-23
  • 2022-01-30
  • 2021-11-09
  • 2021-08-17
相关资源
相似解决方案