在分页页脚中,如果没有找到记录,Page [1 ] of 0 不是应该显示“Page [0 ] of 0”吗?

2024-03-19

我注意到,如果没有要返回的记录,那么分页页脚不应该说“0 of 0”而不是“1 of 0”吗?

另外,分页文本框不应该也被禁用吗?

这是我发送回 jqGrid 的 JSON 响应

{ "total":0, "page":0, "records":0, "rows":[] }

我正在使用 jqGrid 版本 4.5.0

谢谢...

附:源代码如下...

        $('#'+jqgridSpreadsheetId).jqGrid({
            url: '../websrvc/JqGrid.ashx',
            datatype: 'json',
            mtype: 'POST',
            postData: { WhichJqgridTemplate: '<%=JqqridTools.Template.MyInventory%>', WhichAction: '<%=JqqridTools.Action.Display%>', WebpageQuickQuoteSalePrice: '<%=postQuickQuoteSalePrice%>' },
            colNames: ['Id', 'Stock Number', 'VIN', 'Year', 'Make', 'Model', 'Trim', 'Mileage', 'Purchase Price', 'Stock Date', 'Repair Cost', 'Total Cost', 'Days In Inventory', 'Hidden-Inventory-Tracker-Location-Id', 'Inventory Tracker Location', 'Links'],  //Display Text in Column Header...
            colModel: [
                       //In this case, use "sorttype" property in "colModel" for it to work when "loadonce" is set to true...
                       //formatter doc --> "http://www.trirand.com/jqgridwiki/doku.php?id=wiki:predefined_formatter&s[]=cell&s[]=formatter"...
                       //formatter hyperlink --> Stackoverflow posting was said to use formatter's function declaration instead of formatter's "showlink" followed by "formatoptions"...
                       //                    --> (Old Link) - http://stackoverflow.com/questions/5010761/linking-from-a-column-value-in-jqgrid-to-a-new-page-using-get...
                       //                    --> (New Link) - http://stackoverflow.com/questions/14529358/jqgrid-need-hyperlink-need-to-capture-value-through-jquery/14537512#14537512...
                       //                    --> (New Link) - http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_formatter...
                       //                    --> Reasons are --> 1) far simpiler to use formatter for reading/writing and 2) much quicker and better performance...
                       { name: 'Id', index: 'Id', sorttype: 'int', width: 0, align: 'left', hidden: true, hidedlg: true },  //"hidedlg" is use to hide the hidden column in "Column Chooser"...
                       { name: 'StockNumber', index: 'StockNumber', sorttype: 'text', width: 100, align: 'center', searchoptions: { sopt: ['eq', 'ne'] } },
                       { name: 'Vin', index: 'Vin', sorttype: 'text', width: 140, align: 'center', searchoptions: { sopt: ['eq', 'ne'] } },
                       { name: 'Year', index: 'Year', sorttype: 'int', width: 50, align: 'center', searchoptions: { sopt: ['eq', 'ne'] } },
                       { name: 'Make', index: 'Make', sorttype: 'text', width: 80, align: 'center', searchoptions: { sopt: ['eq', 'ne'] } },
                       { name: 'Model', index: 'Model', sorttype: 'text', width: 80, align: 'center', searchoptions: { sopt: ['eq', 'ne'] } },
                       { name: 'Trim', index: 'Trim', sorttype: 'text', width: 100, align: 'center', searchoptions: { sopt: ['eq', 'ne'] } },
                       { name: 'Mileage', index: 'Mileage', sorttype: 'int', width: 60, align: 'center', formatter: 'number', formatoptions: {decimalSeparator:'',thousandsSeparator:',',decimalPlaces:0,defaultValue:'0'} },
                       { name: 'PurchasePrice', index: 'PurchasePrice', sorttype: 'currency', width: 80, align: 'center', formatter: 'currency', formatoptions: {decimalSeparator:'.',thousandsSeparator:',',decimalPlaces:2,defaultValue:'0.00',prefix:'$',suffix:''} },
                       { name: 'StockDate', index: 'StockDate', sorttype: 'date', width: 90, align: 'center', formatter: 'date', formatoptions: { newformat: 'm/d/Y' } },  //"formatter" and "formatoptions" is required for date sorting to works properly...
                       { name: 'RepairCost', index: 'RepairCost', sorttype: 'currency', width: 80, align: 'center', formatter: 'currency', formatoptions: { decimalSeparator: '.', thousandsSeparator: ',', decimalPlaces: 2, defaultValue: '0.00', prefix: '$', suffix: '' } },
                       { name: 'TotalCost', index: 'TotalCost', sorttype: 'currency', width: 80, align: 'center', formatter: 'currency', formatoptions: { decimalSeparator: '.', thousandsSeparator: ',', decimalPlaces: 2, defaultValue: '0.00', prefix: '$', suffix: '' } },
                       { name: 'DaysInInventory', index: 'DaysInInventory', sorttype: 'int', width: 65, align: 'center', formatter: 'number', formatoptions: { decimalSeparator: '', thousandsSeparator: ',', decimalPlaces: 0, defaultValue: '1' } },
                       { name: 'InventoryTrackerLocationId', index: 'InventoryTrackerLocationId', sorttype: 'int', width: 0, align: 'left', hidden: true, hidedlg: true },  //"hidedlg" is use to hide the hidden column in "Column Chooser"...
                       { name: 'InventoryTrackerLocation', index: 'InventoryTrackerLocation', sorttype: 'text', width: 120, align: 'center', searchoptions: { sopt: ['eq', 'ne'] } },
                       //Links is not present in json data from the website, so we customize it here...
                       { name: 'Links', index: 'Links', sorttype: 'text', width: 80, align: 'center', formatter: function (cellValue, options, rowObject) { return "<span style='text-decoration:underline;cursor:pointer;'>Links</span>" }, search: false }  //"search" is use to hide the field in search dialog...
            ],
            beforeSelectRow: function (rowid, e) {
                //http://stackoverflow.com/questions/16592547/how-to-have-custom-formatter-built-in-function-to-call-a-non-jqgrid-seperate-fun
                //http://stackoverflow.com/questions/16592547/how-to-have-custom-formatter-built-in-function-to-call-a-non-jqgrid-seperate-fun
                //http://stackoverflow.com/questions/14529358/jqgrid-need-hyperlink-need-to-capture-value-through-jquery/14537512#14537512
                //http://stackoverflow.com/questions/13761222/how-to-fire-loadcomplete-after-new-row-is-added-in-jqgrid/13765086#13765086
                //To attached javascript function to a clickable "Links" cell...
                if (this.p.colModel[$.jgrid.getCellIndex($(e.target).closest("td")[0])].name === jqgridColumnNameLinks) {
                    jqgridPopupDialogLinkOptions(
                        $(this).getCell(rowid, jqgridColumnIdStockNumber),                //Use $(this) instead for less overhead - It's what Oleg at jqGrid said....
                        $(this).getCell(rowid, jqgridColumnIdVin),                        //Use $(this) instead for less overhead - It's what Oleg at jqGrid said....
                        $(this).getCell(rowid, jqgridColumnIdInventoryTrackerLocationId)  //Use $(this) instead for less overhead - It's what Oleg at jqGrid said....
                    );
                    return false;
                }
            },
            pager: '#'+jqgridPagerId,
            rowNum: 10,
            rowList: [5, 10, 20, 50],  //Drop-down selection in footer - To show how many rows per page...
            //This "sortname"/"sortorder" tag must be specified for "getGridParam"'s 'datatype'/'sortname'/'sortorder' (column sorting) to work.  (Some kind of jqGrid bug or feature which we need to hack to do a workaround with)...
            <%if(postQuickQuoteSalePrice.Length > 0) {%>
            sortname: 'TotalCost', sortorder: 'desc',  //When coming from Quick-Quote webpage...
            <%} else {%>
            sortname: 'StockDate', sortorder: 'desc',  //When coming from any webpages, especially the Product webpage...
            <%}%>
            viewrecords: true,
            //gridview: true,
            //imgpath: '',
            caption: 'My Inventory',
            width: 1022,
            shrinkToFit: false,
            height: 400,
            sortable: true,  /* This allows both 1) Moving columns sideway to other location fields and 2) for jqGrid Column Chooser Plugin / JQuery Multiselect Plugin to work... */
            grouping: true,  /* This allows row data to be group into row grouping... */
            loadonce: true,  //In this case, use "sorttype" property in "colModel" for it to work when "loadonce" is set to true...
            emptyrecords: "No records to display",
            loadError: function (xhr, st, err) {
                alert("An error had occurred, please try again or notify webmaster of this error");
            },
            loadComplete: function () {
                //http://stackoverflow.com/questions/16639339/how-do-i-get-a-column-to-be-sort-in-descending-order-upon-loading...                   
                //=========================================================================================
                // the code will be executed only at the first loading because jqGrid
                // changes datatype to "local" after the first loading if we use
                // loadonce option. We use setTimeout to allows jqGrid to make the first
                // loading till the end and reload it AFTER that
                //=========================================================================================
                var $self = $(this);  //This is needed as seperate objects to seperate itself from the binding jqGrid or $(this) objects for it to work.  It wouldn't work if binded to itself...
                if ($self.jqGrid('getGridParam', 'datatype') === 'json') {  //This the value when loading webpage then the value of "datatype" option will become "local" afterward...
                    //$self.getGridParam({ sortname: 'TotalCost', sortorder: 'desc' });  //When coming from Quick-Quote webpage...
                    //$self.getGridParam({ sortname: 'StockDate', sortorder: 'desc' });  //When coming from any webpages, especially the Product webpage...
                    //$(this).triggerHandler('reloadGrid', [{ sortname: 'Year', sortorder: 'desc' }]);
                    setTimeout(function () {
                        //$('#' + jqgridSpreadsheetId).triggerHandler('reloadGrid', [{ sortname: 'Year', sortorder: 'desc' }]);
                        $self.triggerHandler("reloadGrid");
                    }, 50);
                }
                //=========================================================================================
                jqgridSummarySpreadsheetDisplay();
            }
        });

这是使用 Firefox firebug 的快照。正如您所看到的 json 结果就是您要求我做的,请使用 "page":"0" 而不是 "page":0 。网页中的jqGrid显示1而不是0。


我认为问题在于the line https://github.com/tonytomov/jqGrid/blob/v4.5.2/js/grid.base.js#L1428jqGrid源代码

ts.p.page = $.jgrid.getAccessor(data,dReader.page) || ts.p.page || 0;

您应该更改整数值page to the string value:

{ "total":0, "page":"0", "records":0, "rows":[] }

or

{ "total":"0", "page":"0", "records":"0", "rows":[] }

这基本上完全对应于中描述的格式文档 http://www.trirand.com/jqgridwiki/doku.php?id=wiki%3aretrieving_data#json_data.

UPDATED: The demo http://www.ok-soft-gmbh.com/jqGrid/empty0.htm重现你的问题并另一个演示 http://www.ok-soft-gmbh.com/jqGrid/empty.htm使用固定的 JSON 数据 ("page":"0"代替"page":0)。如何查看修复工作。

更新2:我现在发现问题出在使用loadonce: true。要解决这个问题,可以使用

localReader: {
    page: function (obj) {
        return obj.page !== undefined ? obj.page : "0";
    }
}

see 再一个演示 http://www.ok-soft-gmbh.com/jqGrid/empty1.htm.

更新3: 我已经发布完整的请求 https://github.com/tonytomov/jqGrid/pull/467这将解决问题。该修复已合并(请参阅here https://github.com/tonytomov/jqGrid/commit/db4b24d8373650b76ecbb988c7d4b023f23d2b2d)到github上jqGrid的主要代码。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在分页页脚中,如果没有找到记录,Page [1 ] of 0 不是应该显示“Page [0 ] of 0”吗? 的相关文章

  • jqgrid:拖放多行

    如何使用 jqgrid 拖放多行 即我可以拖动多于一行吗 我怎么知道这在 jqGrid 中是不可能的 jQuery UI 的可排序功能是否支持它 请参阅http jqueryui com demos sortable http jquery
  • jqgrid 增加字体大小时每个单元格周围的间距

    我使用以下 css 增加了网格单元格的字体大小 ui jqgrid ui jqgrid view font size 14px 现在 每个单元格中文本周围的间距都很小 如何增加该空间 以便较大的文本能够在每个单元格中正确显示 预先致谢 更新
  • jqGrid - 防止取消选择行

    使用 jqGrid 如果我再次单击所选行 则该行将被取消选择 有什么办法可以防止这种情况发生吗 我希望该行仍被选中 很好的解决方案 更紧凑的版本 beforeSelectRow function rowid e return this ge
  • jqgrid - 添加、编辑、删除不起作用

    我无法添加 编辑 删除 搜索 即使我输入 editrules required true 也不起作用 firebug 中的错误显示 isEmtpy 不起作用 这是我的代码 索引 html
  • jqGrid 显示用于行内编辑的“编辑”图标

    我正在使用带有内联编辑选项的 jqGrid 如果单元格没有任何值 我想显示一个编辑图标 所以我写了一个格式化程序 function aFormatter cellvalue options row if cellvalue null ret
  • Jqgrid 页脚文本格式问题

    在 Jqgrid 中 我已将某些列设置为链接 对于这些列 我还设置了页脚 MAX 但问题是 配置的链接也被添加到页脚值中 这是意料之外的 任何帮助表示赞赏 提前致谢 我认为问题是how您添加页脚信息 如果你使用页脚数据 http www t
  • 如何获取jqGrid当前的搜索条件?

    我需要获得与 jqGrid 在 GET POST search 参数上传递的完全相同的东西 我怎样才能做到这一点 为了结束这个问题 我做了以下几行 grid getGridParam postData filters 这样我就得到了当我们对
  • 如何将 jqgrid 值作为表单字段提交?

    我正在尝试在用户填写传统表单字段 例如用户名 电话等 的表单中使用 jqGrid 该表单包含用于行项目的 jqGrid 用户可以在其中添加 编辑 删除行 完成后提交整个表格 我让网格按我希望的方式工作 我只是无法将网格的内容作为包含表单的一
  • 使 jqGrid 可移动

    看起来 jqGrid 是基于 jQuery 对话框的 是否有可能使其可移动 像对话框一样 我已经能够将它放在对话框中 但有两个标题栏等看起来很奇怪 我 认为 可以向其中添加必要的类以使其可移动 但我对 jQuery 和 jqGrid 仍然相
  • jqGrid:用双击代替单击进入单元格编辑模式

    Using jqGrid 中的单元格编辑模式 http www trirand com jqgridwiki doku php id wiki cell editing 默认行为是只要单击某个单元格或选择该单元格并按下 Enter 键 就会
  • “JQuery”类型的值不存在属性“jqGrid”

    我将 Typescript 与 jqGrid 和 jQuery 一起使用 在下面一行 jQuery this jqGrid editGridRow rowid 我收到消息 JQuery 类型的值不存在属性 jqGrid 关于如何纠正这个问题
  • jqGrid 复选框列

    我有一个相当复杂的网格 有两列格式化为复选框 这些列定义如下 name Alert A index Alert A width 22 align center sortable false formatter CheckBoxFormatt
  • 当我使用 gridview:true 时, afterInsertRow : function(ids) 方法不执行

    当我设定gridview to true gridview true 在我们的jqGrid中增加jqGrid的性能 方法如下插入行后 或者其他类似的方法不被执行 以下是我的jgGrid的代码 jQuery displaylistGrid j
  • jqGrid 具有自动高度;但有最大高度和滚动条

    有没有办法让jqGrid根据行数自动调整高度 但是当达到一定高度时 它的高度不能再增加并且出现垂直滚动条 Thanks D 我建议你设置 max height 财产在bdiv https stackoverflow com question
  • Jqgrid 模态 Colspan

    我想将 colspan 属性应用于 JQgrid 模式窗口内的 td 它呈现具有以下结构的模态形式
  • 在 MVC 应用程序中显示 jqGrid 页脚行中的数据

    我需要帮助在 jqGrid 页脚行中显示数据 这是我在服务器上的配置 注意用户数据 小时 line Format the data for the jqGrid var jsonData new total totalPages page
  • jqGrid 的排序/过滤问题

    我正在使用jqGrid 4 5 3 版本我已经升级到免费 jqGrid 版本 4 13 6 升级后我面临以下问题 排序不适用于所有列 我想根据我设置的内容显示列大小autoResizable true and autoresizeOnLoa
  • jqgrid在从服务器端重新加载数据期间无法加载特定页面

    我正在使用 jqgrid 3 8 2 我正在尝试使用下面的代码从服务器端重新加载数据并显示特定页面 例如当前页面 mygrid setGridParam datatype json trigger reloadGrid page 5 网格可
  • 使用 jqGrid 的 ASP.NET MVC 路由

    我正在尝试创建一个指向 url 的链接 例如首页 详情 1在 jqGrid 列中 文档显示 showlink baseLinkUrl showAction show addParam key 2 注意 addParam 应该包含 例如 格式
  • 当选择更改时使用 JQuery 进行检测

    我有一个 Jqgrid 它动态生成这样的选择

随机推荐

  • 使用 Popen.stdin 执行多个命令

    我想使用管道在从 python 脚本启动的独立应用程序中执行多个命令 我可以可靠地将命令传递到程序的标准输入的唯一方法是使用 Popen communicate 但它会在命令执行后关闭程序 如果我使用 Popen stdin write 则
  • 如何列出导入的模块及其版本?

    我需要列出所有导入的模块及其版本 我的一些代码仅适用于特定版本 我想保存包的版本 以便将来再次查找 列出包的名称有效 modules list set sys modules set globals print modules 但如果我现在
  • 注入自动映射器

    我一直致力于将 AutoMapper 注入控制器 我喜欢 Code Camp Server 的实现 它围绕 AutoMapper 的 IMappingEngine 创建一个包装器 依赖注入是使用 StructureMap 完成的 但我需要在
  • 有什么办法让 gmaps4rails 在街景中打开地图吗?

    我尝试过更改缩放级别 但它始终保持在地图模式 在wiki上也找不到任何信息 任何帮助或其他建议将不胜感激 最终只使用了 Google 的 Javascript API 事情是这样的 pos new google maps LatLng va
  • 如何将 Knockout js 模型绑定到向导风格的 UI

    我正在使用 Knockout js 我有一个包含对象数组的视图模型 我希望允许用户使用向导样式界面编辑其中一个对象 我遇到的问题是向导将根据所做的选择显示不同的步骤 例如 如果用户在步骤 1 中选择 是 则我将显示步骤 2a 如果用户在步骤
  • 在读取文件之前检查文件是否已打开?

    我正在尝试制作一个小程序 它以非常频繁的间隔 每秒几次 读取本地文件系统 用户计算机 上的文件 然后通过 javascript 将文件的内容提供给网页 小程序需要读取的文件由用户计算机上的程序高频更新 我担心的是 如果小程序在文件更新过程中
  • toDF 的值不是 org.apache.spark.rdd.RDD 的成员

    例外 val people sc textFile resources people txt map split map p gt Person p 0 p 1 trim toInt toDF value toDF is not a mem
  • 在 GNU C 内联汇编中编写 Linux int 80h 系统调用包装器 [重复]

    这个问题在这里已经有答案了 我正在尝试使用内联汇编 我读过这一页http www codeproject com KB cpp edujini inline asm aspx http www codeproject com KB cpp
  • Python 日期时间:昨天的所有项目

    在 Python 中 如果我想检查昨天的所有项目 我会这样做 from datetime import datetime timedelta if datetime datetime today timedelta days 2 lt it
  • C# 将文本转语音保存到 MP3 文件

    我想知道是否有办法将文本到语音数据保存为 mp3 或 Wav 文件格式以便稍后播放 SpeechSynthesizer reader new SpeechSynthesizer reader Rate int 2 reader Speak
  • Windows 键的键码?

    有没有keyCodeWindows 键或用 Javascript 或 jQuery 检测何时按下的方法 I ve dug through StackOverflow and have found how to detect command
  • 如何在 JavaScript 中一次分配多个变量?

    有没有办法在 JavaScript 中执行多重赋值 如下所示 var a b one two 这相当于 var a one var b two 在 ES6 中你可以这样做 var a b one two 上面的代码是 ES6 表示法 称为数
  • 是否可以使用 Spring XML 访问字符串索引的 getter?

    Spring上下文设置XML语言中是否有 字符串索引 getters的概念 假设我有Persongetter 具有以下原型 class Person Person getRelative String relativeName 我可以用类似
  • Java引用同一目录中的类

    我创建了一个PairJava 中的类 类似于 C 对 并且无法从不同的 java 文件引用它 我正在一个 Java 文件中工作 我们称之为fileA在同一目录中Pair class 另外 我还写过package current direct
  • 使用 MVC2 的 AJAX 请求中的 CSRF 保护

    我正在构建的页面很大程度上依赖于 AJAX 基本上 只有一个 页面 并且每次数据传输都是通过 AJAX 处理的 由于浏览器端过度乐观的缓存会导致奇怪的问题 数据未重新加载 因此我必须使用 POST 执行所有请求 也读取 这会强制重新加载 现
  • React Native/Redux 应用程序中可能存在导航问题

    在使用 Redux 在大型 React Native 应用程序中导航期间 所有访问的场景 导航堆栈中的场景 都保持安装状态 当从最后一个场景组件调度任何动作时 所有这些场景都会接收道具并按照访问它们的顺序进行渲染 它会导致调度和最后一个场景
  • 如何使用消息代理和数据库设计分布式应用程序?

    我想实现一个分布式销售点系统 有点像中描述的系统销售点应用程序架构建议 https stackoverflow com questions 2454629 point of sale app architecture advice 它是一个
  • 如何pickle python 函数及其依赖项?

    作为这个问题的后续 有没有一种简单的方法来pickle python 函数 或以其他方式序列化其代码 https stackoverflow com questions 1253528 is there an easy way to pic
  • 为什么 JVM 不从数据库加载类?

    为什么Java虚拟机不从数据库加载类 类似于 NET的GAC 据我了解 目前它必须读取并扫描类路径上每个 JAR 的清单才能找到类文件 使用数据库 如 SQLite 不会缩短启动时间吗 之所以没有 是因为没有人将其添加到标准库中 此外 出于
  • 在分页页脚中,如果没有找到记录,Page [1 ] of 0 不是应该显示“Page [0 ] of 0”吗?

    我注意到 如果没有要返回的记录 那么分页页脚不应该说 0 of 0 而不是 1 of 0 吗 另外 分页文本框不应该也被禁用吗 这是我发送回 jqGrid 的 JSON 响应 total 0 page 0 records 0 rows 我正