为什么使用gridview:true,它是什么意思? [英] Why is gridview:true used for and what does it mean?

查看:183
本文介绍了为什么使用gridview:true,它是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究JqGrid.

I am working on JqGrid.

我想知道如果指定gridview:true是什么意思.

I want to know what does it mean if we specify gridview:true.

在什么情况下我们需要提供?

And in what cases do we need to provide ?

我最近正在使用一个这样的jqGrid,而我的afterInsertRow没有被调用,一旦我删除了gridview:true,现在就可以进行调用了.

I recently was working on one such jqGrid and my afterInsertRow was not being called, once I remvoed the gridview:true now the call is made.

这是我本人经历的一种情况,我想知道是否还有其他情况,如果使用gridview:true,我们应该知道.

This is one case that I myself experienced, I was wondering if there are other cases too which we should know if gridview:true is used.

请指导我.

推荐答案

我同意文档中对gridview: true选项的解释不好.在某些情况下(例如在TreeGrid中),该选项将被自动设置.因此,我尝试解释它的含义以及为什么我建议始终使用gridview: true选项,而从不使用afterInsertRow.

I agree that gridview: true option is not good explained in the documentation. In some cases (like in case of TreeGrid) the option will be automatically set. So I try to explain what it mean and why I recommend always to use the gridview: true option and the never use afterInsertRow.

许多人以其他一些计算机语言(如JavaScript)开始,并编写了他的第一个程序,这种程序在具有某种程序编写风格之后便在网络浏览器中运行. 3年前,我遇到了同样的问题. 重要的是要了解在HTML页面上进行一些更改后网络浏览器必须做什么.在使用jQuery的过程中,这就是您永久要做的事情.

Many people start with some other computer languages as JavaScript and write his first program which run in web browser after they have some style of writing of programs. I had the same problem 3 year before. It's important to understand what the web browser have to do after you make some changes on the HTML page. In usage of usage of jQuery it's the thing what you permanently do.

如果更改页面上的某些DOM元素,则可以更改页面上所有其他DOM元素上的位置.如果您考虑浮动模型(例如float: left)或许多其他CSS设置,您将会理解Web浏览器不能仅仅移动现有页面的位图表示并插入新插入的元素.因此, Web浏览器必须重新计算页面上所有现有元素的位置,并将其中一些元素移到另一个位置.即使更改元素的CSS样式,也会发生所谓的重排.建议您阅读文章,并查看有关该主题的视频.

If you change some DOM element on the page the position on all other DOM element existing on the page can be changed. If you think about floating model (like with float: left) or many other CSS settings you will understand that web browser can't just move the bitmap representation of the existing page and insert the new inserted element. So the web browser have to recalculate of position all element existing on the page and move some from the elements on another place. Even if you change CSS style of an element the so named reflow take place. I'd recommend you to read the article and to look the video about the subject.

在上述情况下,提高Web浏览器性能的主要思想是减少页面上的更改次数.因此,您需要更改一个DOM元素的5种样式,所以您应该在一次操作中执行此操作.您可以将jQuery.css({...})与所有更改的样式一起使用,而不用使用5个单独的调用.更好的办法是定义一个CSS类并使用jQuery.addClass方法.

The main idea to improve performance of web browser the the described above case will be to reduce the number of changes on the page. So is you need to change 5 styles of one DOM elements you should do this in one operation. You can use jQuery.css({...}) with all the changed styles instead of 5 separate calls. Even better could be to define one CSS class and use jQuery.addClass method.

对于jqGrid,需要用网格的所有行和单元格填充<tbody>.如果使用gridview: true选项,则jqGrid将所有行的内容收集为带有HTML片段的字符串.稍后jqGrid在该行在内部设置innerHTML属性以设置页面上的整个HTML片段.

In case of jqGrid one need to fill <tbody> with all rows and cells of the grid. If you use gridview: true option then jqGrid collect the content of all rows as strings with HTML fragments. Later jqGrid call jQuery.append in the line which set internally innerHTML property to set the whole HTML fragment on the page.

由于相同的原因,您应该使用cellattrrowattr

Because of the same reason you should use cellattr, rowattr or custom formatters which works with HTML fragments represented the cells or rows as strings. At the end the strings will be appended to other strings and will be used in jQuery.append operation like I described above.

使用afterInsertRow回调函数需要在调用afterInsertRow回调之前将网格的每一行放置在页面上 .因此,不可能使用gridview: true选项并使页面工作缓慢.

The usage of afterInsertRow callback function require that every row of the grid will be placed on the page before calling of afterInsertRow callback. So it makes impossible the usage of gridview: true option and make working of the page slowly.

准确地说,我刚才提到的性能下降只有在大网格的情况下才可见,而在Web浏览器速度慢的情况下(如Internet Explorer,尤其是旧版本的IE),在大多数情况下是显而易见的.

To be exact I should mention that the performance decreasing which I described before could be visible only in case of large grid and will be mostly clear seen in case of slow web browser (like Internet Explorer, especially old versions of IE).

这篇关于为什么使用gridview:true,它是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆