flexigrid https://www.e-learn.cn/tag/flexigrid zh-hans 【华磊随笔】善于使用工具(1)-使用IE8开发人员工具和FireBug分析Jquery FlexiGrid的实现原理 https://www.e-learn.cn/topic/3550644 <span>【华磊随笔】善于使用工具(1)-使用IE8开发人员工具和FireBug分析Jquery FlexiGrid的实现原理</span> <span><span lang="" about="/user/70" typeof="schema:Person" property="schema:name" datatype="">蹲街弑〆低调</span></span> <span>2020-04-06 22:37:58</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"> <p>作者: <a href="http://www.cnblogs.com/hualei/" rel="nofollow">华磊</a> 发表于 2010-08-20 22:27 <a href="http://www.cnblogs.com/hualei/archive/2010/08/20/1805006.html" rel="nofollow">原文链接</a> 阅读: 706 评论: 6</p> <p>【华磊随笔】善于使用工具(1)-使用IE8开发人员工具和FireBug分析Jquery FlexiGrid的实现原理 </p> <p> </p> <p><span style="color: red; font-size: 14pt;"><strong>"工欲善其事,必先利其器" </strong></span></p> <p><span style="font-size: 12pt;">当今Web开发,如何有效的提升用户操作体验已经越来越重要,以现在的技术而言,Javascript 操作dom和style是最有效的手段;Web开发不像Windows开发一样,往往要涉及到很多不同的技术和方向;同时,由于机制的原因和技术的分散,快速有效方便的调试Javascript很大程度上会直接影响到我们实际的开发效率。 </span></p> <p><span style="font-size: 12pt;">    笔者自1999年就开始涉猎Web开发,最早时抱着本HTML参考手册,开着记事本就开始写网页了,所谓的调试就是不停的增加alert来跟踪程序的执行状态;实话说,10余年了,由于技术本身的特点,Web脚本的调试方法并没有像其他语言一样有着明显的进步;我还是经常看到一些开发人员用alert进行代码的跟踪,不得不认为是这个领域的悲剧现象。 </span></p> <p><span style="font-size: 12pt;">    但就最近两年,由Mozilla、Google、Apple几大巨头又重新点燃了浏览器战场的硝烟,同时,也由于竞争,使得主流的浏览器产品也进入了快速发展的黄金时期;浏览器的功能不断升级,调试手段的不断改进,执行效率的不断提升,同时也提供了更多好的工具和方法来进行更快更方面的Web脚本调试;其中的较好的首推 IE8开发人员工具和FireBug。 </span></p> <p><span style="font-size: 12pt;">    笔者并不想一个功能一个功能的介绍,只想分享最近工作的一些心得和体会,更希望通过解决问题的过程和方法给大家带来一些思考。 </span></p> <p><span style="color: red; font-size: 14pt;">主场景:分析Jquery FlexiGrid的机制和原理,将其用在自己的项目中。 </span></p> <p><span style="font-size: 12pt;">笔者最近需要实现一个新的asp.net Grid控件替换现用的控件,开始的时候根据实际的需求对javascript grid方案进行了解和研究,主要针对功能、代码结构、产生的Dom结构、异步交互的机制等方面进行对比分析,最终选择了Jquery FlexiGrid,功能和代码结构的分析没什么好说的,针对异步交互和Dom结构则用到了一些工具帮助快速的进行分析。 </span></p> <p><span style="color: red; font-size: 14pt;">场景一:使用FireBug分析FlexiGrid的异步交互机制 </span></p> <p><span style="font-size: 12pt;">Firebug是FireFox中非常好的一个插件,用来分析dom模型、网络传输、调试js、研究样式等非常使用;本场景下使用Friebug对FlexiGrid的异步交互进行分析。 </span></p> <p><span style="font-size: 12pt;">首先在FireFox中安装Firebug,直接使用ff访问<a href="http://getfirebug.com/" rel="nofollow"></a></span>http://getfirebug.com/<span style="font-size: 12pt;"> ,直接点击<img class="b-lazy" data-src="http://images.cnblogs.com/cnblogs_com/hualei/082010_1426_11.png" data-original="http://images.cnblogs.com/cnblogs_com/hualei/082010_1426_11.png" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" />根据提示安装。 </span></p> <p><span style="font-size: 12pt;">重启FF后在Firefox中开启(点击状态栏右下的<img class="b-lazy" data-src="http://images.cnblogs.com/cnblogs_com/hualei/082010_1426_12.png" data-original="http://images.cnblogs.com/cnblogs_com/hualei/082010_1426_12.png" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" />图标),像下面这个样子: </span></p> <p><img class="b-lazy" data-src="http://images.cnblogs.com/cnblogs_com/hualei/082010_1426_13.png" data-original="http://images.cnblogs.com/cnblogs_com/hualei/082010_1426_13.png" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /><span style="font-size: 12pt;"> </span></p> <p><span style="font-size: 12pt;">我们用到的是网络面板,用来跟踪页面的网络交互情况;切换到网络面板,开启网络跟踪 </span></p> <p><img class="b-lazy" data-src="http://images.cnblogs.com/cnblogs_com/hualei/082010_1426_14.png" data-original="http://images.cnblogs.com/cnblogs_com/hualei/082010_1426_14.png" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /><span style="font-size: 12pt;"> </span></p> <p><span style="font-size: 12pt;">在FF中打开FlexiGrid的演示项目(本文中直接使用http://flexigrid.info/站点),在firebug网络面板中开始显示跟踪网络交互的结果。 </span></p> <p><img class="b-lazy" data-src="http://images.cnblogs.com/cnblogs_com/hualei/082010_1426_15.png" data-original="http://images.cnblogs.com/cnblogs_com/hualei/082010_1426_15.png" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /><span style="font-size: 12pt;"> </span></p> <p><span style="font-size: 12pt;">嗯,非常实用,我们能清晰的跟踪到打开该页面的所有网络交互,并能够清晰的看到每一条请求的url,状态码,域名,大小,时间线,同时还能看到汇总的情况;我的网络的确很慢。大部分数据来自缓存,打开http://flexigrid.info/还是用了4.8秒,<span style="color: red;"><strong>其中,蓝色时间线(Timeline)标志着DomContentOnload(jquery $(document).read,概念大家不陌生吧)的截止点,红色时间线标志Onload截止点,最后一条请求的终点嘛,则是所有Request的终止点</strong></span>。下图清晰地对time line进行了说明和解释。 </span></p> <p><img class="b-lazy" data-src="http://images.cnblogs.com/cnblogs_com/hualei/082010_1426_16.png" data-original="http://images.cnblogs.com/cnblogs_com/hualei/082010_1426_16.png" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /><span style="font-size: 12pt;"> </span></p> <p><span style="font-size: 12pt;">针对网络面板更专业的解释,参见(<a href="http://www.softwareishard.com/blog/firebug/firebug-net-panel-timings/" rel="nofollow">http://www.softwareishard.com/blog/firebug/firebug-net-panel-timings/</a>)英文,介绍的很清晰。 </span></p> <p><span style="font-size: 12pt;">回到我们的场景,我们通过XHR查看xmlrequest的请求情况,并仔细查看FlexiGrid的请求和响应的数据(可以称之为协议)。 </span></p> <p><img class="b-lazy" data-src="http://images.cnblogs.com/cnblogs_com/hualei/082010_1426_17.png" data-original="http://images.cnblogs.com/cnblogs_com/hualei/082010_1426_17.png" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /><span style="font-size: 14pt;"> </span></p> <p><img class="b-lazy" data-src="http://images.cnblogs.com/cnblogs_com/hualei/082010_1426_18.png" data-original="http://images.cnblogs.com/cnblogs_com/hualei/082010_1426_18.png" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /><span style="font-size: 14pt;"> </span></p> <p><span style="font-size: 12pt;">很好很干净,请求模式用了Post,连get参数都没有(firebug会根据当前的请求展现不同的信息,比如如果有get参数,则会显示get面板,上例返回了json数据,则显示了json面板),post参数很简单(这个场景应用也简单,具体操作时我会针对相对复杂的例子进行分析),返回的数据格式么,标准的json对象,包含了一个rows的数组,嗯,也很简单。用在我的控件里,可以通过get参数传递我的额外信息,json么,标准的格式,按样生成一个就好了。 </span></p> <p><span style="font-size: 12pt;">对比起来,FlexiGrid很好很简单,很适合改造和应用,异步交互上满足要求。 </span></p> <p><span style="font-size: 12pt;">其实:本例介绍的是使用工具来快速的分析和调试页面脚本,实际笔者的选择过程非常痛苦,此处不再累述。 </span></p> <p><span style="color: red; font-size: 12pt;"><strong>总结一下收获:我们通过firebug跟踪页面的网络请求情况,针对具体的xmlrequest我们分析了具体的请求数据,同时,通过时间线,我们能很清楚的分析页面的加载速度,js执行速度和缓存的应用情况。 </strong></span></p> <p> </p> <p><span style="color: red; font-size: 14pt;"><strong>场景二:通过分析脚本执行所产生的Dom模型(顺带看看样式) </strong></span></p> <p><span style="font-size: 12pt;">IE8开发人员工具和FireBug一样是非常强大的工具,实话说,我升级到IE8的唯一理由就是开发人员工具;我们通过这两个工具来实际分析脚本的dom处理结果,看看干净程度、dom结构合理吗。 </span></p> <p><span style="font-size: 12pt;">首先是FireBug,切换到html页,刷下网页或者控件做点事情,关键是在页面展现的是我们需要分析的操作结果。 </span></p> <p><img class="b-lazy" data-src="http://images.cnblogs.com/cnblogs_com/hualei/082010_1426_19.png" data-original="http://images.cnblogs.com/cnblogs_com/hualei/082010_1426_19.png" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /><span style="color: red; font-size: 14pt;"><strong> </strong></span></p> <p><span style="font-size: 12pt;">的确,看到了很多信息,不过一层层找着看的确很累,<img class="b-lazy" data-src="http://images.cnblogs.com/cnblogs_com/hualei/082010_1426_110.png" data-original="http://images.cnblogs.com/cnblogs_com/hualei/082010_1426_110.png" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" />就很实用,选中后直接点击页面你想看到的地方,html面板就自动切换到对应的上下文,我是通过随便选中了一个Grid的td,然后往上找的。 </span></p> <p style="margin-left: 42pt;"><span style="font-size: 12pt;">右边面板显示了很多东西 </span></p> <ul><li> <div style="text-align: justify;"> <span style="font-size: 12pt;">样式中我们能方便的找到到底是哪些样式(哪文件,哪行代码)影响到当前元素,甚至可以改改看看效果。 </span> </div> </li> <li> <div style="text-align: justify;"> <span style="font-size: 12pt;">计算出的样式则是根据上下文进行计算,给出当前元素的的大多数样式的计算取值(希望我没理解错)。 </span> </div> </li> <li> <div style="text-align: justify;"> <span style="font-size: 12pt;">布局不解释。 </span> </div> </li> <li> <div style="text-align: justify;"> <span style="font-size: 12pt;">Dom么,查看当前元素的dom节点的属性、方法的取值和跟踪(参考vside中的快速监视)。 </span> </div> </li> </ul><p><span style="font-size: 12pt;">接下来是IE8开发人员工具,同样我们打开网页执行操作后,在工具菜单打开(或者直接F12)。 </span></p> <p><img class="b-lazy" data-src="http://images.cnblogs.com/cnblogs_com/hualei/082010_1426_111.png" data-original="http://images.cnblogs.com/cnblogs_com/hualei/082010_1426_111.png" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /><span style="font-size: 12pt;"> </span></p> <p><span style="font-size: 12pt;">和FireBug类似,提供HTML面板和<img class="b-lazy" data-src="http://images.cnblogs.com/cnblogs_com/hualei/082010_1426_112.png" data-original="http://images.cnblogs.com/cnblogs_com/hualei/082010_1426_112.png" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" />,嗯大体差不多,跟踪样式差不多就是firebug的计算样式,属性相当于Dom(不过感觉还是差些)。 </span></p> <p><span style="font-size: 12pt;">看起来,这两款工具很强大,设计师们可以跟踪样式来分析、设计和优化自己的样式表,对于程序员来说,都很实用,用来分析他人的网页和成果,很方便。 </span></p> <p><span style="font-size: 12pt;">回到场景,我们可以看出,FlexiGrid的Dom机制主要是根据选择的table,产生了6个div和里面的无数表格和元素 </span></p> <p><span style="font-size: 12pt;">.nBtn Div:绝对定位的浮动层,用于显示控制Grid的列的按钮,该层中的元素根据表头的mouse事件动态产生,显示 </span></p> <p><img class="b-lazy" data-src="http://images.cnblogs.com/cnblogs_com/hualei/082010_1426_113.png" data-original="http://images.cnblogs.com/cnblogs_com/hualei/082010_1426_113.png" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /><span style="font-size: 12pt;">。 </span></p> <p><span style="font-size: 12pt;">.nDiv Div:绝对定位的浮动层,生成一个表格,用于显示控制Grid的列的控制面板的显示和隐藏,显示 </span></p> <p><img class="b-lazy" data-src="http://images.cnblogs.com/cnblogs_com/hualei/082010_1426_114.png" data-original="http://images.cnblogs.com/cnblogs_com/hualei/082010_1426_114.png" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /><span style="font-size: 12pt;">。 </span></p> <p><span style="font-size: 12pt;">.hDiv Div:相对位置的层,负责展示表头,内部生成一个只有thead的表格,同时用作存储表格的列的控制参数,基本上FlexiGrid主要通过hDiv来查询列的配置(比如说列名,排序等),并处理大量表头事件。 </span></p> <p><span style="font-size: 12pt;">.cDrag Div:负责列宽拖放的层,响应事件来调整列宽。 </span></p> <p><span style="font-size: 12pt;">.bDiv Div:包含实际表格数据的层,基本上看到的表格数据都是在这里处理,内部产生一个只有tbody的表格,其中tr对应具体的行,tr的id为row+id(异步返回的Json中的行id)。 </span></p> <p><span style="font-size: 12pt;">其实还有2个,用于分页器跟快速查询,这个演示中没有显示出来。 </span></p> <p><span style="font-size: 12pt;">OK,Dom结构还算清晰,一层一层点下去看,比较干净,每个元素基本都有对应的用处。FlexiGrid再次过关。(实际情况复杂和困惑一些)。 </span></p> <p> </p> <p><span style="color: red; font-size: 12pt;"><strong>总结:IE8开发人员工具和FireBug可以方便的跟踪页面的Dom结构,具体元素的样式、dom属性方法、布局;两个工具都可以动态的对Dom Css Html进行编辑,并立刻在浏览器中看到效果。 </strong></span></p> <p> </p> <p><span style="font-size: 12pt;">OK,通过上述的分析和理解FlexiGrid入围,我们最终选中它作为我们的控件展示部分的基础。 </span></p> <p> </p> <p><span style="font-size: 12pt;">下一次将具体到dotNetFlexGrid的开发过程,通过若干场景为大家分享一些Javascript 的调试和优化技巧。</span></p> <img width="1" height="1" alt="" class="b-lazy" data-src="http://www.cnblogs.com/hualei/aggbug/1805006.html?type=1" data-original="http://www.cnblogs.com/hualei/aggbug/1805006.html?type=1" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /><p>评论: 6 <a href="http://www.cnblogs.com/hualei/archive/2010/08/20/1805006.html#pagedcomment" rel="nofollow">查看评论</a> <a href="http://www.cnblogs.com/hualei/archive/2010/08/20/1805006.html#commentform" rel="nofollow">发表评论</a></p> <p><a href="http://job.cnblogs.com/" rel="nofollow">程序员找工作,就在博客园</a></p> <p>最新新闻:<br />· <a href="http://news.cnblogs.com/n/71681/" rel="nofollow">大公司是如何走上开源之路的</a><span style="color:gray">(2010-08-23 13:30)</span><br />· <a href="http://news.cnblogs.com/n/71680/" rel="nofollow">Firefox 4.0 Beta 4 RC 下载</a><span style="color:gray">(2010-08-23 13:22)</span><br />· <a href="http://news.cnblogs.com/n/71679/" rel="nofollow">盛大Bambook零售价999元 9月28日正式上市</a><span style="color:gray">(2010-08-23 13:19)</span><br />· <a href="http://news.cnblogs.com/n/71678/" rel="nofollow">周鸿祎:开心网该学Zynga而不是Facebook</a><span style="color:gray">(2010-08-23 13:12)</span><br />· <a href="http://news.cnblogs.com/n/71673/" rel="nofollow">蝶变Acorn:撬动英特尔与苹果</a><span style="color:gray">(2010-08-23 12:57)</span><br /></p> <p>编辑推荐:<a href="http://kb.cnblogs.com/page/71661/" rel="nofollow">热点新闻:腾讯收购康盛创想</a><br /></p> <p>网站导航:<a href="http://www.cnblogs.com">博客园首页</a>  <a href="http://home.cnblogs.com/" rel="nofollow">个人主页</a>  <a href="http://news.cnblogs.com">新闻</a>  <a href="http://home.cnblogs.com/ing/" rel="nofollow">闪存</a>  <a href="http://home.cnblogs.com/group/" rel="nofollow">小组</a>  <a href="http://space.cnblogs.com/q/" rel="nofollow">博问</a>  <a href="http://space.cnblogs.com">社区</a>  <a href="http://kb.cnblogs.com">知识库</a></p> <div class="alert alert-success" role="alert"><p>来源:<code>oschina</code></p><p>链接:<code>https://my.oschina.net/u/96280/blog/6860</code></p></div></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/flexigrid" hreflang="zh-hans">flexigrid</a></div> <div class="field--item"><a href="/tag/hualei" hreflang="zh-hans">华磊</a></div> <div class="field--item"><a href="/tag/firebug" hreflang="zh-hans">firebug</a></div> </div> </div> Mon, 06 Apr 2020 14:37:58 +0000 蹲街弑〆低调 3550644 at https://www.e-learn.cn 比Jquery FlexiGrid更好用 dotnetFlexGrid 1.2beta更新-增加展现模板模式(Grid中可以放编辑控件和任意Html内容了) https://www.e-learn.cn/topic/3450793 <span>比Jquery FlexiGrid更好用 dotnetFlexGrid 1.2beta更新-增加展现模板模式(Grid中可以放编辑控件和任意Html内容了)</span> <span><span lang="" about="/user/80" typeof="schema:Person" property="schema:name" datatype="">我是研究僧i</span></span> <span>2020-02-29 23:16:30</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"> <p>作者: <a href="http://www.cnblogs.com/hualei/" rel="nofollow">华磊</a> 发表于 2010-08-19 21:29 <a href="http://www.cnblogs.com/hualei/archive/2010/08/19/1803969.html" rel="nofollow">原文链接</a> 阅读: 126 评论: 0</p> <p>累,先看效果,前两天提问表格内不能编辑的朋友开心了:</p> <p> </p> <div style="float: left;"> <img width="400" class="b-lazy" data-src="http://pic002.cnblogs.com/img/hualei/201008/2010081921241035.jpg" data-original="http://pic002.cnblogs.com/img/hualei/201008/2010081921241035.jpg" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /></div> <div style="float: left;"> <img class="b-lazy" data-src="http://pic002.cnblogs.com/img/hualei/201008/2010082101265512.jpg" data-original="http://pic002.cnblogs.com/img/hualei/201008/2010082101265512.jpg" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /></div> <div style="clear: both;"> <p> </p> <p>2010-8-19 v1.2 beta</p> <ul><li> 修复快速查询时的键盘回车事件与控件外围事件的冲突的问题。 </li> <li> 修复快速查询时设置正则表达式时可能导致的语法错误的问题。 </li> <li> 数据提供方法DataHandler将不再强制要求与列的绑定顺序一致,现在通过返回的DataTable中的ColumnName自动绑定到合适的列,所以,请保证您的DataTable和控件中的列名一致(区分大小写)。 </li> <li> 增加展现模板的功能,现InitConfig初始化时针对列配置增加了一个itemTemplate属性,该属性提供了当前列的展现模板设定。 </li> <li> 演示项目中FirstGrid.aspx增加了客户端刷新、服务端刷新和快速查询功能的演示。 </li> <li> 演示项目中TestTemplate.aspx提供了使用展现模板的演示。 </li> </ul><p>下载请访问首页置顶链接</p> <p>简介请访问 <a href="http://www.cnblogs.com/hualei/archive/2010/08/17/1801500.html" rel="nofollow">JQuery FlexiGrid的asp.net完美解决方案:dotNetFlexGrid-.Net原生的异步表格控件 简介和应用效果截图</a></p> <p>使用指南请访问 <a href="http://www.cnblogs.com/hualei/archive/2010/08/17/1801850.html" rel="nofollow">JQuery FlexiGrid的asp.net完美解决方案-dotNetFlexGrid使用指南(一)</a></p> <p> </p> </div> <img width="1" height="1" alt="" class="b-lazy" data-src="http://www.cnblogs.com/hualei/aggbug/1803969.html?type=1" data-original="http://www.cnblogs.com/hualei/aggbug/1803969.html?type=1" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /><p>评论: 0 <a href="http://www.cnblogs.com/hualei/archive/2010/08/19/1803969.html#pagedcomment" rel="nofollow">查看评论</a> <a href="http://www.cnblogs.com/hualei/archive/2010/08/19/1803969.html#commentform" rel="nofollow">发表评论</a></p> <p><a href="http://job.cnblogs.com/" rel="nofollow">程序员找工作,就在博客园</a></p> <p>最新新闻:<br />· <a href="http://news.cnblogs.com/n/71681/" rel="nofollow">大公司是如何走上开源之路的</a><span style="color:gray">(2010-08-23 13:30)</span><br />· <a href="http://news.cnblogs.com/n/71680/" rel="nofollow">Firefox 4.0 Beta 4 RC 下载</a><span style="color:gray">(2010-08-23 13:22)</span><br />· <a href="http://news.cnblogs.com/n/71679/" rel="nofollow">盛大Bambook零售价999元 9月28日正式上市</a><span style="color:gray">(2010-08-23 13:19)</span><br />· <a href="http://news.cnblogs.com/n/71678/" rel="nofollow">周鸿祎:开心网该学Zynga而不是Facebook</a><span style="color:gray">(2010-08-23 13:12)</span><br />· <a href="http://news.cnblogs.com/n/71673/" rel="nofollow">蝶变Acorn:撬动英特尔与苹果</a><span style="color:gray">(2010-08-23 12:57)</span><br /></p> <p>编辑推荐:<a href="http://kb.cnblogs.com/page/71661/" rel="nofollow">热点新闻:腾讯收购康盛创想</a><br /></p> <p>网站导航:<a href="http://www.cnblogs.com">博客园首页</a>  <a href="http://home.cnblogs.com/" rel="nofollow">个人主页</a>  <a href="http://news.cnblogs.com">新闻</a>  <a href="http://home.cnblogs.com/ing/" rel="nofollow">闪存</a>  <a href="http://home.cnblogs.com/group/" rel="nofollow">小组</a>  <a href="http://space.cnblogs.com/q/" rel="nofollow">博问</a>  <a href="http://space.cnblogs.com">社区</a>  <a href="http://kb.cnblogs.com">知识库</a></p> <div class="alert alert-success" role="alert"><p>来源:<code>oschina</code></p><p>链接:<code>https://my.oschina.net/u/96280/blog/6858</code></p></div></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/flexigrid" hreflang="zh-hans">flexigrid</a></div> <div class="field--item"><a href="/tag/jquery" hreflang="zh-hans">jquery</a></div> </div> </div> Sat, 29 Feb 2020 15:16:30 +0000 我是研究僧i 3450793 at https://www.e-learn.cn how do you pass parameters in asmx using Flexigrid? https://www.e-learn.cn/topic/3061449 <span>how do you pass parameters in asmx using Flexigrid?</span> <span><span lang="" about="/user/50" typeof="schema:Person" property="schema:name" datatype="">拜拜、爱过</span></span> <span>2020-01-02 08:29:22</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>here's my code:</p> <pre><code>$('#flex1').flexigrid({ method: 'POST', url: '/services/MHService.asmx/GetSurgicalHistory', dataType: 'xml', colModel: [ { display: 'Surgical Procedure', name: 'SurgicalProcedure', width: 120, sortable: true, align: 'left' }, { display: 'Notes', name: 'Notes', width: 120, sortable: true, align: 'left' }, { display: 'Complications', name: 'Complications', width: 120, sortable: true, align: 'left' } ], searchitems: [ { display: 'Surgical Procedure', name: 'SurgicalProcedure' }, { display: 'Notes', name: 'Notes' }, { display: 'Complications', name: 'Complications' } ], sortname: 'SurgicalProcedure', singleSelect: true, sortorder: 'asc', usepager: true, title: 'Surigcal History', useRp: true, rp: 10, showTableToggleBtn: true, width: 805, height: 200 }); </code></pre> <p>Now this code works, how do i pass parameters in the webservice? i tried looking for the 'data' parameter in the Flexigrid api, but there seems to be none.</p> <p>something like this:</p> <pre><code> method: 'POST', url: '/services/MHService.asmx/GetSurgicalHistory', dataType: 'xml', data: '{ id: 23, area: "anywhere" }', </code></pre> <br /><h3>回答1:</h3><br /><p>what I ended up doing was this on line 713 of flexigrid.js i add this</p> <pre><code> for(opt in p.optional){ param[param.length] = {name:opt,value:p.optional[opt]}; } </code></pre> <p>then I could do something like this </p> <pre><code> $('#flex1').flexigrid({ method: 'POST', url: '/services/MHService.asmx/GetSurgicalHistory', dataType: 'xml', colModel: [ { display: 'Surgical Procedure', name: 'SurgicalProcedure', width: 120, sortable: true, align: 'left' }, { display: 'Notes', name: 'Notes', width: 120, sortable: true, align: 'left' }, { display: 'Complications', name: 'Complications', width: 120, sortable: true, align: 'left' } ], searchitems: [ { display: 'Surgical Procedure', name: 'SurgicalProcedure' }, { display: 'Notes', name: 'Notes' }, { display: 'Complications', name: 'Complications' } ], sortname: 'SurgicalProcedure', singleSelect: true, sortorder: 'asc', usepager: true, title: 'Surigcal History', useRp: true, rp: 10, showTableToggleBtn: true, width: 805, height: 200, optional: { id: 23, area: "anywhere" } }); </code></pre> <p>its not great but I really could find any other way and I don't see any new versions coming out anytime soon 8 ^ )</p> <br /><br /><br /><h3>回答2:</h3><br /><p>Change:</p> <pre><code>data: '{ id: 23, area: "anywhere" }', </code></pre> <p>to:</p> <pre><code>params: [{name:'id', value: 23},{name:'area', value: 'anywhere'}], </code></pre> <p>Or if you want to reload with new Options:</p> <pre><code>$("#flex1").flexOptions({params: [{name:'id', value: 23},{name:'area', value: 'anywhere'}]}).flexReload(); </code></pre> <br /><br /><br /><h3>回答3:</h3><br /><p>Additional parameters can be specified using the params: option. If you look at line 615-618 in flexigrid.js, you can see where the code loops through each item in p.params, and adds it to the default list (page, rp, sortname, etc).</p> <br /><br /><br /><h3>回答4:</h3><br /><p>You should try this here:</p> <p>http://bargaorobalo.net/blog/flexigrid-passar-parametros</p> <p>Its in portuguese, but means that you PASS additionals parameters to json:</p> <pre><code>useRp : true, rp : 10, params: [{name:'ID', value: 100}] </code></pre> <p>and RECEIVE in json setting variable:</p> <pre><code>$query = isset($_POST['query']) ? $_POST['query'] : false; $qtype = isset($_POST['qtype']) ? $_POST['qtype'] : false; $id = isset($_POST['ID']) ? $_POST['ID'] : NULL; </code></pre> <p>Now, you just use this parameter in your SQL CODE:</p> <pre><code>$sql = "SELECT * FROM PROCEDURE_NAME(".$id.") $where $sort $limit"; $result = runSQL($sql); </code></pre> <br /><br /><br /><h3>回答5:</h3><br /><p>if you try to load flexigrid data for a particular value in some click Event. try this we can use the query string like a </p> <pre><code> var val1=value; url: '/services/MHService.asmx/GetSurgicalHistory?qurid='+val1, </code></pre> <p>to the webservice method and get from webservice using string </p> <p><code>getvalue=HttpContext.Current.Request.QueryString["qurid"].ToString();</code></p> <br /><br /><br /><h3>回答6:</h3><br /><p>You can use the flexOptions in the onSubmit event when initializing flexigrid, like this:</p> <pre><code>... title: 'Surigcal History', onSubmit: function() { $('#flex1').flexOptions({newp:1,params:[{name: 'id', value: '23'}]}); $('#flex1').flexOptions({newp:1,params:[{name: 'area', value: 'anywhere'}]}); }, useRp: true, ... </code></pre> <p>better to use a loop for multiple parameters</p> <p>This avoids modifying the flexigrid.js directly </p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/3323865/how-do-you-pass-parameters-in-asmx-using-flexigrid</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/web-services" hreflang="zh-hans">web-services</a></div> <div class="field--item"><a href="/tag/asmx" hreflang="zh-hans">asmx</a></div> <div class="field--item"><a href="/tag/flexigrid" hreflang="zh-hans">flexigrid</a></div> </div> </div> Thu, 02 Jan 2020 00:29:22 +0000 拜拜、爱过 3061449 at https://www.e-learn.cn FlexiGrid “No Items”, response clearly shows data https://www.e-learn.cn/topic/2944115 <span>FlexiGrid “No Items”, response clearly shows data</span> <span><span lang="" about="/user/140" typeof="schema:Person" property="schema:name" datatype="">你说的曾经没有我的故事</span></span> <span>2019-12-25 14:48:42</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>Table is visible, looks fine, column headers show up, but after a split second of "processing, please wait..." the status goes to "No Items". Inspecting the response in the DOM shows the data is being returned properly from the web service, formatted as follows:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;MyDataClass xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/"&gt; &lt;Page&gt;1&lt;/Page&gt; &lt;Rows&gt; &lt;MyDataRow&gt; &lt;request_id&gt;13073&lt;/request_id&gt; &lt;status&gt;501&lt;/status&gt; &lt;req_by_user_id&gt;herbjm&lt;/req_by_user_id&gt; &lt;/MyDataRow&gt; ... .... &lt;/Rows&gt; &lt;/MyDataClass&gt; </code></pre> <p>Here is the flexigrid javascript in question:</p> <pre><code>$('#report').flexigrid({ url: 'reportdata.asmx/rptPendingServerRequestsFlexi', dataType: 'xml', colModel: [ { display: 'ID', name: 'request_id', width: 40, sortable: true, align: 'center' }, { display: 'Status', name: 'status', width: 180, sortable: true, align: 'left' }, { display: 'Requested By', name: 'req_by_user_id', width: 120, sortable: true, align: 'left' } ], searchitems: [ { display: 'ID', name: 'request_id' }, { display: 'Status', name: 'status', isdefault: true }, { display: 'Requested By', name: 'req_by_user_id' } ], sortname: "request_id", sortorder: "desc", usepager: false, title: 'Server Requests', useRp: false, rp: 30, showTableToggleBtn: false, singleSelect: true }); </code></pre> <p>And for bonus points, how can I show the footer even if paging is diabled?</p> <p><strong>UPDATE:</strong> I inspected the DOM for the flexigrid demo and here is how their returned XML is formatted:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;rows&gt; &lt;page&gt;1&lt;/page&gt; &lt;total&gt;239&lt;/total&gt; &lt;row id='1'&gt; &lt;cell&gt;1&lt;/cell&gt; &lt;cell&gt;501&lt;/cell&gt; &lt;cell&gt;Steve&lt;/cell&gt; &lt;/row&gt; &lt;row id='2'&gt; &lt;cell&gt;2&lt;/cell&gt; &lt;cell&gt;501&lt;/cell&gt; &lt;cell&gt;Fred&lt;/cell&gt; &lt;/row&gt; &lt;/rows&gt; </code></pre> <p>I'm guessing that's why it's not working? To see how I'm building the response, please see this question: vb.net return json object with multiple types?</p> <br /><h3>回答1:</h3><br /><p>According to various information I have found here and a couple of other locations, flexigrid requires the XML to have specific format:</p> <pre><code>rows - the row definition page - the current page number total - the total count of rows in this collection row - the row, with a unique property called id cell - each row must contain cells in the order that they are displayed on the grid </code></pre> <p>Since the MyDataClass was generated as a result of your previous question, here are updated versions of those classes that will produce the desired output:</p> <pre><code>&lt;XmlType("rows")&gt; _ Public Class MyDataClass &lt;XmlElement("page")&gt; _ Public Property Page As Integer &lt;XmlElement("total")&gt; _ Public ReadOnly Property Total As Integer Get If Me.Rows IsNot Nothing Then Return Me.Rows.Count Else Return 0 End If End Get End Property &lt;XmlElement("row")&gt; _ Public Property Rows As List(Of MyDataRow) ' Parameterless constructor to support serialization. Public Sub New() Me.Rows = New List(Of MyDataRow) End Sub Public Sub New(wPage As Integer, ds As DataSet) Me.New() Me.Page = wPage For Each oRow As DataRow In ds.Tables(0).Rows Dim oMyRow As New MyDataRow oMyRow.Id = CInt(oRow("id")) oMyRow.Name = CStr(oRow("Name")) Me.Rows.Add(oMyRow) Next End Sub End Class &lt;XmlType("row")&gt; _ Public Class MyDataRow &lt;XmlAttribute("id")&gt; _ Public Property Id As Integer Private m_cCells As List(Of MyDataCell) &lt;XmlIgnore()&gt; _ Public WriteOnly Property Name As String Set(value As String) Me.AddCell("Name", value) End Set End Property &lt;XmlElement("cell")&gt; _ Public ReadOnly Property Cells As List(Of MyDataCell) Get Return m_cCells End Get End Property ' Parameterless constructor to support serialization Public Sub New() m_cCells = New List(Of MyDataCell) End Sub Public Sub AddCell(sCellName As String, sCellValue As String) m_cCells.Add(New MyDataCell(sCellName, sCellValue)) End Sub End Class Public Class MyDataCell &lt;XmlIgnore()&gt; _ Public Property Name As String &lt;XmlText()&gt; _ Public Property Value As String ' Parameterless constructor to support serialization Public Sub New() End Sub Public Sub New(sCellName As String, sCellValue As String) Me.New() Me.Name = sCellName Me.Value = sCellValue End Sub End Class </code></pre> <br /><br /><br /><h3>回答2:</h3><br /><p>Guys have a look of this demo of flexiuigrid</p> <p>http://flexidemo.ranjitjena.com/</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/14223125/flexigrid-no-items-response-clearly-shows-data</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/jquery" hreflang="zh-hans">jquery</a></div> <div class="field--item"><a href="/tag/ajax" hreflang="zh-hans">ajax</a></div> <div class="field--item"><a href="/tag/vbnet" hreflang="zh-hans">vb.net</a></div> <div class="field--item"><a href="/tag/flexigrid" hreflang="zh-hans">flexigrid</a></div> </div> </div> Wed, 25 Dec 2019 06:48:42 +0000 你说的曾经没有我的故事 2944115 at https://www.e-learn.cn FlexiGrid “No Items”, response clearly shows data https://www.e-learn.cn/topic/2944090 <span>FlexiGrid “No Items”, response clearly shows data</span> <span><span lang="" about="/user/81" typeof="schema:Person" property="schema:name" datatype="">人盡茶涼</span></span> <span>2019-12-25 14:48:19</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>Table is visible, looks fine, column headers show up, but after a split second of "processing, please wait..." the status goes to "No Items". Inspecting the response in the DOM shows the data is being returned properly from the web service, formatted as follows:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;MyDataClass xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/"&gt; &lt;Page&gt;1&lt;/Page&gt; &lt;Rows&gt; &lt;MyDataRow&gt; &lt;request_id&gt;13073&lt;/request_id&gt; &lt;status&gt;501&lt;/status&gt; &lt;req_by_user_id&gt;herbjm&lt;/req_by_user_id&gt; &lt;/MyDataRow&gt; ... .... &lt;/Rows&gt; &lt;/MyDataClass&gt; </code></pre> <p>Here is the flexigrid javascript in question:</p> <pre><code>$('#report').flexigrid({ url: 'reportdata.asmx/rptPendingServerRequestsFlexi', dataType: 'xml', colModel: [ { display: 'ID', name: 'request_id', width: 40, sortable: true, align: 'center' }, { display: 'Status', name: 'status', width: 180, sortable: true, align: 'left' }, { display: 'Requested By', name: 'req_by_user_id', width: 120, sortable: true, align: 'left' } ], searchitems: [ { display: 'ID', name: 'request_id' }, { display: 'Status', name: 'status', isdefault: true }, { display: 'Requested By', name: 'req_by_user_id' } ], sortname: "request_id", sortorder: "desc", usepager: false, title: 'Server Requests', useRp: false, rp: 30, showTableToggleBtn: false, singleSelect: true }); </code></pre> <p>And for bonus points, how can I show the footer even if paging is diabled?</p> <p><strong>UPDATE:</strong> I inspected the DOM for the flexigrid demo and here is how their returned XML is formatted:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;rows&gt; &lt;page&gt;1&lt;/page&gt; &lt;total&gt;239&lt;/total&gt; &lt;row id='1'&gt; &lt;cell&gt;1&lt;/cell&gt; &lt;cell&gt;501&lt;/cell&gt; &lt;cell&gt;Steve&lt;/cell&gt; &lt;/row&gt; &lt;row id='2'&gt; &lt;cell&gt;2&lt;/cell&gt; &lt;cell&gt;501&lt;/cell&gt; &lt;cell&gt;Fred&lt;/cell&gt; &lt;/row&gt; &lt;/rows&gt; </code></pre> <p>I'm guessing that's why it's not working? To see how I'm building the response, please see this question: vb.net return json object with multiple types?</p> <br /><h3>回答1:</h3><br /><p>According to various information I have found here and a couple of other locations, flexigrid requires the XML to have specific format:</p> <pre><code>rows - the row definition page - the current page number total - the total count of rows in this collection row - the row, with a unique property called id cell - each row must contain cells in the order that they are displayed on the grid </code></pre> <p>Since the MyDataClass was generated as a result of your previous question, here are updated versions of those classes that will produce the desired output:</p> <pre><code>&lt;XmlType("rows")&gt; _ Public Class MyDataClass &lt;XmlElement("page")&gt; _ Public Property Page As Integer &lt;XmlElement("total")&gt; _ Public ReadOnly Property Total As Integer Get If Me.Rows IsNot Nothing Then Return Me.Rows.Count Else Return 0 End If End Get End Property &lt;XmlElement("row")&gt; _ Public Property Rows As List(Of MyDataRow) ' Parameterless constructor to support serialization. Public Sub New() Me.Rows = New List(Of MyDataRow) End Sub Public Sub New(wPage As Integer, ds As DataSet) Me.New() Me.Page = wPage For Each oRow As DataRow In ds.Tables(0).Rows Dim oMyRow As New MyDataRow oMyRow.Id = CInt(oRow("id")) oMyRow.Name = CStr(oRow("Name")) Me.Rows.Add(oMyRow) Next End Sub End Class &lt;XmlType("row")&gt; _ Public Class MyDataRow &lt;XmlAttribute("id")&gt; _ Public Property Id As Integer Private m_cCells As List(Of MyDataCell) &lt;XmlIgnore()&gt; _ Public WriteOnly Property Name As String Set(value As String) Me.AddCell("Name", value) End Set End Property &lt;XmlElement("cell")&gt; _ Public ReadOnly Property Cells As List(Of MyDataCell) Get Return m_cCells End Get End Property ' Parameterless constructor to support serialization Public Sub New() m_cCells = New List(Of MyDataCell) End Sub Public Sub AddCell(sCellName As String, sCellValue As String) m_cCells.Add(New MyDataCell(sCellName, sCellValue)) End Sub End Class Public Class MyDataCell &lt;XmlIgnore()&gt; _ Public Property Name As String &lt;XmlText()&gt; _ Public Property Value As String ' Parameterless constructor to support serialization Public Sub New() End Sub Public Sub New(sCellName As String, sCellValue As String) Me.New() Me.Name = sCellName Me.Value = sCellValue End Sub End Class </code></pre> <br /><br /><br /><h3>回答2:</h3><br /><p>Guys have a look of this demo of flexiuigrid</p> <p>http://flexidemo.ranjitjena.com/</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/14223125/flexigrid-no-items-response-clearly-shows-data</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/jquery" hreflang="zh-hans">jquery</a></div> <div class="field--item"><a href="/tag/ajax" hreflang="zh-hans">ajax</a></div> <div class="field--item"><a href="/tag/vbnet" hreflang="zh-hans">vb.net</a></div> <div class="field--item"><a href="/tag/flexigrid" hreflang="zh-hans">flexigrid</a></div> </div> </div> Wed, 25 Dec 2019 06:48:19 +0000 人盡茶涼 2944090 at https://www.e-learn.cn Grid - When should you switch from html to server side table processing? https://www.e-learn.cn/topic/2796791 <span>Grid - When should you switch from html to server side table processing?</span> <span><span lang="" about="/user/45" typeof="schema:Person" property="schema:name" datatype="">妖精的绣舞</span></span> <span>2019-12-23 05:38:10</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>,This question is likely subjective, but a lot of "grid" Javascript plugins have come out to help paginate and sort tables. They usually work in 2 ways, the first and simplest is that it takes an existing HTML <code>&lt;table&gt;</code> and converts it into a sortable and searchable information. The second is that it passes info to the server and has the server select info from the database to be displayed.</p> <p>My question is this: <strong>At what point (size wise) is it more efficient to use server-side processing vs displaying all the data and have the "grid plugin" convert it to a sortable/searchable table client-side?</strong></p> <p>Using datatables as an example, I have to execute at least 3 queries to get total rows in the table, total filtered results for pagination, and the filtered results to be displayed for the specific selected page. Then every time I sort, I am querying again. Every time I move to another page, or search in the table, more queries.</p> <p>If I was to pull the data once when the client visits the page, I would be executing a single query, and then formatting and pushing the results to the client all at once. This increases the page size, and possibly delays loading of the page once it gets too big. The upside is there will only one query, and all the sorting, searching, and pagination is handled by the plugin, so no waiting for a response and no more queries.</p> <p>If I was to have just a few rows, I imagine just pushing the formatted table data to the client at the page load would be the fastest. But with thousands of rows, switching to server-side would be the most efficient way.</p> <p>Where is the tipping point? Is there a tipping point, or is server-side or client-side the way to go 100% of the time?</p> <br /><h3>回答1:</h3><br /><p>The answer on your question can be only subjective. So I explain how I personally understand the problem and give me recommendation.</p> <p>In my opinion the data with 2-3 row and 3-4 column can be displayed in HTML table without usage any plugin. The data you display for the user the more important will be that the user will be able <strong>to grasp</strong> the information which will be displayed. So I think that the information for example have to be good formatted and marked with colors and icons for example. This with help to grasp information from probably 10 rows of data, but not much more. If you just display table with 100 rows or more then you <strong>overtax</strong> the user. The user will have to analyse the data to get any helpful information from the table. Scrolling of the data makes this not easier.</p> <p>So I think that one should give the user comfortable or at least convenient interface <strong>to sort and to filter</strong> the data from the table. The exact interface is mostly the matter of taste. For example the grid can have an additional filter bar</p> <p></p><p></p><p></p><img class="b-lazy" data-src="https://www.eimg.top/images/2020/03/24/a17c91ab25c0ab39c738a7fb9cf1652c.png" data-original="https://www.eimg.top/images/2020/03/24/a17c91ab25c0ab39c738a7fb9cf1652c.png" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /><p></p><p></p> <p>For filtering and even for sorting of the data it's important to have not pure strings, but to be able to distinguish the data types like <code>integer</code> (10 should be after 9 and not between 1 and 2), <code>numbers</code> (correct interpret '.' and ',' inside of numbers), <code>dates</code> (<code>3/20/2012</code> should be grater as <code>4/15/2010</code>) and so on. If you just <strong>convert</strong> HTML table to some grid you will have problems with correct filtering or sorting. Even if you use pure <em>local</em> JavaScript data to display in grid it would be important to have datasource which has some kind of type information and then to create the grid based in the data. In the case you can gives date as JavaScript <code>Date</code> or as ISO 8601 string "2012-03-20" and in the grid display the data corresponds the specified formatter as <code>3/20/2012</code> or <code>20-Mar-2012</code>.</p> <p>Whether you implement filtering, sorting and paging on the server side or on the client side is not really important for the user who open the page. It's important only that all works quickly enough. The exact choose of the grid plugin, the filtering (with filter toolbar or external controls) and styling of the grid depend on your taste and the project requirements.</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/9793780/grid-when-should-you-switch-from-html-to-server-side-table-processing</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/ajax" hreflang="zh-hans">ajax</a></div> <div class="field--item"><a href="/tag/jqgrid" hreflang="zh-hans">jqgrid</a></div> <div class="field--item"><a href="/tag/datatables" hreflang="zh-hans">datatables</a></div> <div class="field--item"><a href="/tag/flexigrid" hreflang="zh-hans">flexigrid</a></div> </div> </div> Sun, 22 Dec 2019 21:38:10 +0000 妖精的绣舞 2796791 at https://www.e-learn.cn Adding data to jQuery-Flexigrid without ajax-request https://www.e-learn.cn/topic/2791935 <span>Adding data to jQuery-Flexigrid without ajax-request</span> <span><span lang="" about="/user/191" typeof="schema:Person" property="schema:name" datatype="">末鹿安然</span></span> <span>2019-12-23 04:41:46</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I want to save some unneeded requests and time for displaying a table the first time and so I thought maybe I could set the initial data directly without any ajax-request. I tried it like that:</p> <pre><code>$('#testTable').flexAddData('[formatted json here]'); </code></pre> <p>and also that</p> <pre><code>$('#testTable').addData('[formatted json here]'); </code></pre> <p>But it hasn't any effect. Can I do that and what is the right syntax?</p> <br /><h3>回答1:</h3><br /><p>Did you use the <code>eval()</code>?</p> <pre><code>$("#testTable").flexAddData(eval('[formatted json here]')); </code></pre> <p>or try </p> <pre><code>$("#testTable").flexAddData(eval('[formatted json here]')).flexReload(); </code></pre> <p>hope this helps</p> <br /><br /><br /><h3>回答2:</h3><br /><p>I've also met this problem and spent a lot of time trying to solve it. Solution in my case was pretty simple. You just need to specify dataType : "json" obviously in <code>flexigrid()</code> function. Default dataType is XML. So, it don't want to understand JSON: </p> <pre><code>$("#myTable").flexigrid({dataType : "json"}); </code></pre> <br /><br /><br /><h3>回答3:</h3><br /><p>To supplement <strong>Anwar</strong> and <strong>user1635430</strong> answers, here is an example JSON code:</p> <pre><code>{ "page": "1", "total": "9", "rows": [ { "id": "1", "cell": [ "1", "text1", "user1", "date1" ] } ] } </code></pre> <p>The code is done by <strong>Anwar</strong>, I "stole" it from his answer on some other question.</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/8912543/adding-data-to-jquery-flexigrid-without-ajax-request</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/javascript" hreflang="zh-hans">javascript</a></div> <div class="field--item"><a href="/tag/jquery" hreflang="zh-hans">jquery</a></div> <div class="field--item"><a href="/tag/flexigrid" hreflang="zh-hans">flexigrid</a></div> </div> </div> Sun, 22 Dec 2019 20:41:46 +0000 末鹿安然 2791935 at https://www.e-learn.cn Changing Jquery FlexGrid's data https://www.e-learn.cn/topic/2786955 <span>Changing Jquery FlexGrid&#039;s data</span> <span><span lang="" about="/user/91" typeof="schema:Person" property="schema:name" datatype="">给你一囗甜甜゛</span></span> <span>2019-12-23 03:25:15</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I am having a flex grid. I need to change the data which is showing in that.</p> <p>In $(document).ready() I am calling a function and I am getting the result.Now what i want is to get data from db using another query.So I just made a function, in that i am adding the needed values to fetch the data in the url.This function is calling when I click a button .But the request is not going .So that is not changing.Please Help me. Thanks</p> <pre><code> $(document).ready(function() { getAllData(); //first call $(".datebetweenList").click(function() { getDataBetweenDates(); //secondcall change in url }); }); // Calls First function getAllData() { $("#flex1").flexigrid ({ url: '../Handlers/AjaxGetData.ashx?isFlexi=&lt;%=Request.QueryString["ass"]%&gt;&amp;bid=' + document.getElementById("&lt;%=ddlBranch.ClientID%&gt;").value, dataType: "json", colModel: [ { display: 'Sl No', name: 'SlNo', width: 10, hide: true, sortable: false, align: 'center' }, { display: 'Sl No', name: 'SlNo', width: 60, sortable: false, align: 'center' }, { display: 'Code', name: 'asset_Code', width: 180, sortable: true, align: 'left' }, { display: 'Name', name: 'asset_Name', width: 150, sortable: true, align: 'left' }, { display: 'Serial No', name: 'asset_Sl_No', width: 150, sortable: true, align: 'left' }, { display: 'Category', name: 'asset_Category', width: 150, sortable: true, align: 'left' }, { display: 'Location', name: 'location_Name', width: 150, sortable: true, align: 'left' }, { display: 'Qty', name: 'qty', width: 150, sortable: true, align: 'left' }, { display: 'Status', name: 'status', width: 150, sortable: true, align: 'left' }, { display: 'Report', name: 'Report', width: 150, sortable: false, align: 'left' } ], buttons: [ ], searchitems: [ { display: 'Asset Name', name: 'asset_Name' } ], sortname: "asset_Name", sortorder: "asc", usepager: true, singleSelect: true, title: "Asset Stock Report", useRp: true, rp: 15, showTableToggleBtn: true, width: 1240, height: 200 }); } //Calls Second [on clicking a button] function getDataBetweenDates() { $("#flex1").flexigrid ({ url: '../Handlers/AjaxGetData.ashx?isFlexi=&lt;%=Request.QueryString["ass"]%&gt;&amp;bid=' + document.getElementById("&lt;%=ddlBranch.ClientID%&gt;").value + '&amp;isDate=1&amp;eDate=' + document.getElementById("&lt;%=txtEndDate.ClientID%&gt;").value + '&amp;sDate=' + document.getElementById("&lt;%=txtStartDate.ClientID%&gt;").value, dataType: "json", colModel: [ { display: 'Sl No', name: 'SlNo', width: 10, hide: true, sortable: false, align: 'center' }, { display: 'Sl No', name: 'SlNo', width: 60, sortable: false, align: 'center' }, { display: 'Code', name: 'asset_Code', width: 180, sortable: true, align: 'left' }, { display: 'Name', name: 'asset_Name', width: 150, sortable: true, align: 'left' }, { display: 'Serial No', name: 'asset_Sl_No', width: 150, sortable: true, align: 'left' }, { display: 'Category', name: 'asset_Category', width: 150, sortable: true, align: 'left' }, { display: 'Location', name: 'location_Name', width: 150, sortable: true, align: 'left' }, { display: 'Qty', name: 'qty', width: 150, sortable: true, align: 'left' }, { display: 'Status', name: 'status', width: 150, sortable: true, align: 'left' }, { display: 'Report', name: 'Report', width: 150, sortable: false, align: 'left' } ], buttons: [ ], searchitems: [ { display: 'Asset Name', name: 'asset_Name' } ], sortname: "asset_Name", sortorder: "asc", usepager: true, singleSelect: true, title: "Asset Stock Report", useRp: true, rp: 15, showTableToggleBtn: true, width: 1240, height: 200 }); } </code></pre> <br /><h3>回答1:</h3><br /><p>I got the answer.</p> <p>We can able to pass the value in option</p> <pre><code> $('#flex1').flexOptions({ url: 'a.apsx'?id=1' }).flexReload(); </code></pre> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/5064493/changing-jquery-flexgrids-data</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/c" hreflang="zh-hans">c#</a></div> <div class="field--item"><a href="/tag/jquery-plugins" hreflang="zh-hans">jquery-plugins</a></div> <div class="field--item"><a href="/tag/jquery" hreflang="zh-hans">jquery</a></div> <div class="field--item"><a href="/tag/flexigrid" hreflang="zh-hans">flexigrid</a></div> </div> </div> Sun, 22 Dec 2019 19:25:15 +0000 给你一囗甜甜゛ 2786955 at https://www.e-learn.cn Codeigniter: using datagrid https://www.e-learn.cn/topic/2770495 <span>Codeigniter: using datagrid</span> <span><span lang="" about="/user/128" typeof="schema:Person" property="schema:name" datatype="">别等时光非礼了梦想.</span></span> <span>2019-12-22 13:57:08</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>i'm looking for implement datagrid with CI, better if using ajax.</p> <p>Searching on Google i've found many tutorial and discussion on how to use <strong>Flexigrid-4-CI</strong> or <strong>jqGrid</strong>, anyway i'm still confused on which one could offer more flexibility.</p> <p>For example, is it possible to set more than one field to filter results with Flexigrid? Besides extending my search i found other libraries such as CarboGrid or datagrid-CI.</p> <p>Does anyone tried that stuff? What's your suggestion? CarboGrid looks really interesting...</p> <br /><h3>回答1:</h3><br /><p>I am using datatables, simple, clean, and fast under 1000 rows.</p> <br /><br /><br /><h3>回答2:</h3><br /><p>I have found a few actively on development</p> <p>phpGrid - A lot of features<br /> SmartGrid - Simple grid with bootstrap support<br /> Grocery CRUD Datagrid - A framework with Datagrid</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/5245795/codeigniter-using-datagrid</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/codeigniter" hreflang="zh-hans">codeigniter</a></div> <div class="field--item"><a href="/tag/datagrid" hreflang="zh-hans">datagrid</a></div> <div class="field--item"><a href="/tag/jqgrid" hreflang="zh-hans">jqgrid</a></div> <div class="field--item"><a href="/tag/flexigrid" hreflang="zh-hans">flexigrid</a></div> </div> </div> Sun, 22 Dec 2019 05:57:08 +0000 别等时光非礼了梦想. 2770495 at https://www.e-learn.cn Grails getProperties method does not always return properties in the correct order https://www.e-learn.cn/topic/2431325 <span>Grails getProperties method does not always return properties in the correct order</span> <span><span lang="" about="/user/45" typeof="schema:Person" property="schema:name" datatype="">妖精的绣舞</span></span> <span>2019-12-13 03:44:10</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I have a class that looks like this:</p> <pre><code>class Foo { name description static constraints = { name() description() } } </code></pre> <p>I want to add display instances of my class in a Flexigrid. When data is sent to a flexigrid it needs to be in a format like JSON or XML... I have chosen JSON. Flexigrid expects JSON arrays it receives to have the following format:</p> <pre><code>{ "page": "1", "total": "1", "rows": [ { "id": "1", "cell": [ "1", "The name of Foo 1", "The description of Foo 1" ] }, { "id": "2", "cell": [ "2", "The name of Foo 2", "The description of Foo 2" ] } ] } </code></pre> <p>To get my <code>Foo</code> objects into this format I do something similar to this:</p> <pre><code>def foos = Foo.getAll( 1, 2 ) def results = [:] results[ "page" ] = params.page results[ "total" ] = foos.size() results[ "rows" ] = [] for( foo in foos ) { def cell = [] cell.add( foo.id ) foo.getProperties().each() { key, value -&gt; // Sometimes get foo.getProperties().each() returns foo.description then foo.name instead of foo.name then foo.description as desired. cell.add( value.toString() ) } results[ "rows" ].add( [ "id": foo.id, "cell": cell ] ) } render results as JSON </code></pre> <p>The problem is that every once in a while <code>foo.getProperties().each()</code> returns <code>foo.description</code> then <code>foo.name</code> resulting in <code>foo.description</code> being put in the name column of my flexigrid and <code>foo.name</code> being put in the description column of my flexigrid for a specific row.</p> <p>I tried specifying constraints in the <code>Foo</code> domain class so the <code>getProperties</code> would return in the correct order, but it didn't work. <strong>How can I make sure <code>getProperties</code> returns properties in a predictable order?</strong></p> <p><strong>This is how I fixed this issuse:</strong></p> <pre><code>def items = Foo.getAll() for( item in items ) { def cell = [] cell.add( item.id ) Foo.constraints.each() { key, value -&gt; def itemValue = item.getProperty( key ) if( !( itemValue instanceof Collection ) ) { cell.add( itemValue.toString() ) } } } </code></pre> <p>So <code>Foo.constraints</code> gets a map of constraints where each constraint is an instance of <code>Collections$UnmodifiableMap$UnmodifiableEntrySet$UnmodifiableEntry</code>. After testing I have found this map always returns my <code>Foo</code> static constraints in the order I entered them (also confirmed by Ian). Now only the properties of the <code>item</code> which are in <code>Foo.constraints</code> will be added to the <code>cell</code> for flexigrid.</p> <br /><h3>回答1:</h3><br /><p>I don't think <code>foo.getProperties()</code> guarantees anything about the ordering. But <code>Foo.constraints</code> is overridden at runtime to return not the original closure, but a <code>Map</code> of <code>ConstrainedProperty</code> objects and the keys in this map <em>are</em> guaranteed to be in the same order as the constraints closure (this is how scaffolding is able to use the constraints ordering to define the order in which fields are presented in the scaffolded views). So you could do something like</p> <pre><code>def props = [:] // [:] declares a LinkedHashMap, so order-preserving Foo.constraints.each { k, v -&gt; props[k] = foo."${k}" } </code></pre> <br /><br /><br /><h3>回答2:</h3><br /><p><code>foo.getProperties().sort()</code> or if there's no good way to sort the properties in the order you need, you could always define the order of the properties yourself in a list to iterate over.</p> <pre><code>def properties = ['name', 'description'] properties.each { cell.add(foo."$it") } </code></pre> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/11150476/grails-getproperties-method-does-not-always-return-properties-in-the-correct-ord</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/json" hreflang="zh-hans">json</a></div> <div class="field--item"><a href="/tag/grails" hreflang="zh-hans">grails</a></div> <div class="field--item"><a href="/tag/groovy" hreflang="zh-hans">groovy</a></div> <div class="field--item"><a href="/tag/flexigrid" hreflang="zh-hans">flexigrid</a></div> </div> </div> Thu, 12 Dec 2019 19:44:10 +0000 妖精的绣舞 2431325 at https://www.e-learn.cn