English 中文(简体)
在重新装入 Jqgrid 时重新装入滚滚 - 复制行数据并丢失最后一页时的问题
原标题:Issue while reloading Jqgrid with Scroll - Duplicate row data and missing last page

请参见下面我用来从数据库上载数据的代码。 代码只要在第一次上载数据, 就会正常工作。 每个记录和每页都完美地载荷 。

现在如果我叫重新装入函数,它就会产生问题。

  1. Sometime it loads duplicate rows (say if my jason returning 20 rows, grid will show 40)
  2. I loose the last page of the records in grid.

 jQuery("#list").jqGrid({
            url: "http://localhost/myapp/myfile.php",
            datatype: "json",                
            mtype:"POST",
            postData:{folder:  INBOX  },
            jsonReader: 
            {
                root: "rows",
                page: "currpage",
                total: "totalpages",
                records: "totalrecords",
                id: "0",
                cell:"",
                repeatitems: false
            },
            colNames: [ Id , Message ],
            colModel: [ 
                        { name:  messageid , index:  messageid , hidden: true, search:false},
                        { name:  message , index:  message , search:false},
                      ],
            rowNum: 10,
            scroll: 1,
            prmNames:{npage:1},
            autowidth: true,
            height: 470,
            loadonce: true,
            viewrecords: true,
            altRows:true,                
            caption: "",
            pager: "#plist",
        });
        jQuery("#list").jqGrid( setFrozenColumns );

    function reload_list()
    {
        $("#list").setGridParam({datatype: json }).trigger( reloadGrid );
    }

请注意以下资料:

框架一M使用 JqGrid 版本的“强”jqGrid.jqGrid-4.3.1

我输入密码的档案是

  1. css/ui.jqgrid.css
  2. js/grid.locale-en.js
  3. js/jquery.jqGrid.src.js
  4. plugins/grid.postext.js
  5. src/jqModal.js
  6. src/jqDnR.js

DEMO:http://www.trimantra.com/demo/apointmentsystem/grid.php' rel=“nofollow'>http://www.trimantra.com/demo/appointmentsystem/grid.php

Please Let me know How I can resolve this issue. Thanks in advance.

问题回答

从代码中删除此行 :

jQuery("#list").jqGrid( setFrozenColumns );

正因为如此,它才创建了新的一行。

我无法再重复列重复的问题, 但我可以看到很多其它问题 在您的申请中。

我想您的主要问题在于您在所有三个网格中都以相同的 ids < / strong > 输入数据。 正如您在页面上的 ID 重复结果一样。 解决问题的最简单方法是使用 jqGrid 的 < code> id Prefix 选项 。

以下是我发现的最重要问题清单:

  • You included incorrectly jQuery UI in your application. You don t included images subdirectory of the theme. So the application get "HTTP/1.1 404 Not Found" error on the loading of http://www.trimantra.com/demo/appointmentsystem/lib/jquery.jqGrid-4.3.1/themes/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png. You should include all images in your project.
  • You don t use idPrefix option in the grids and load the same data in three grids. As the result all three grids will have <tr> elements with the same id. HTML don t allow id duplication. To fix the problem you can use for example idPrefix: "a", idPrefix: "b", idPrefix: "c" for the three grids. As the results the row having messageid: "45" will get id="a45" in the first grid, id="b45" and id="c45" in the last grid and you will have no id duplicates on the page.
  • I see no sense in combination of scroll: 1 and loadonce: true. If I understand what you need to do you should just remove scroll: 1 and prmNames:{npage:1} from all grids. The options are needed for virtual scrolling.
  • You should add gridview: true option which will improve performance of grids in many times in case of large number of rows.
  • The server response which produce the server currently not corresponds the jqGrid request. The request will contains rows=10, page=1, sidx=toname, sord=asc. The server returns all 48 rows of data and the data are unsorted. In any way you should insert sorting of data in your server code.
  • You use frozen:true in all visible columns. I see no sense in the settings.
  • If you don t need to display messageid column you can just remove the column definition from the colModel and use jsonReader: {id: "messageid", repeatitems: false }. As the results the will save place on the page (hidden columns still get place on the page).
  • You should better transfer dates in locale independent format ISO 8601. Additionally you should use formatter: data to display the dates in the format like 05/16/2012 07:45 AM which you use you can use formatoptions: { newformat: "d/m/Y H:i A" }. The main benefit will be correct sorting order of the column in case of usage loadonce: true.
  • You should remove trailing commas from colModel definitions. The combination },] is an error in JavaScript. The error will be ignored in the most modern web browsers (but not in old like IE6). It s better to write error free code.




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签