<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
	<title>jQuery Grid Plugin - jqGrid - Topic: Default options, multiselect, extend</title>
	<link>http://www.trirand.com/blog/?page_id=393/bugs/default-options-multiselect-extend</link>
	<description><![CDATA[Grid plugin]]></description>
	<generator>Simple:Press Version 5.7.5.3</generator>
	<atom:link href="http://www.trirand.com/blog/?page_id=393/bugs/default-options-multiselect-extend/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>tony on Default options, multiselect, extend</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/default-options-multiselect-extend#p1365</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/default-options-multiselect-extend#p1365</guid>
        	        	<description><![CDATA[<p>Thanks,</p>
<p>I will try this.</p>
<p>Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Mon, 04 Aug 2008 04:30:35 +0300</pubDate>
        </item>
        <item>
        	<title>Creativebyte on Default options, multiselect, extend</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/default-options-multiselect-extend#p1344</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/default-options-multiselect-extend#p1344</guid>
        	        	<description><![CDATA[<p>Hello tony,</p>
<p>I read your previous post again and you fell for the same mistake that was the basis for this bug report: You did a simple exted and not a deep copy! It seems that the second level of the options array (in your case the rowList) is not copied but linked, which causes the overwrite. So, if you do a deep copy like I suggested</p>
<p>$.extend(true,$.jgrid.defaults,{rowList:[10,20,30]});</p>
<p>you won&#39;t have any problems 🙂</p>
</p>
<p>On the other side, I use a different approach. I don&#39;t want to mess with the defaults since you never know if you won&#39;t get a new module in the app where you need to change it all back. Most of my grids (90%) use a lot of common options and they only differ in minor things (like postData and stuff).</p>
<p>My solution was quite simple. I have a default array per "grid group" where I store all common options and a specific options array for each grid in that group to set the specific options or even override the ones in my default array.</p>
<p>Having this, I run the extend function (deep copy!) on both arrays and get a combination of both in return. After doing this, I pass this array on to jqGrid. By doing this, the jqgrid default array remains untouched but I can define my own defautl array per group. maybe, this could be an enhancement for the library?</p>
<p>My idea would be: let the developer define multiple default arrays (named) when setting up the library.THis default woudl sit on top of the standard default array.</p>
<p>On each grid, he can choose whether to use the standard default array or one of the ones he specified before. Afterwards, he could overwrite those values as well as he can do now with the standard default array.</p>
<p>So, all I want to say is: why not bring an additional layer in between the standard default array and the grid specific options? In my code this would be really helpful (that&#39;s why I do this already but outside the library).</p>
]]></description>
        	        	<pubDate>Fri, 01 Aug 2008 08:02:12 +0300</pubDate>
        </item>
        <item>
        	<title>tony on Default options, multiselect, extend</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/default-options-multiselect-extend#p1327</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/default-options-multiselect-extend#p1327</guid>
        	        	<description><![CDATA[<p>I think that we should support a wide range of possibilities. By example in my project I want to have in all grids this option rowList:[10,20,30], but in particular page I do not want this. Setting the rowList as common option have sence in relative big project, but what to do in a particular case when I do not want this? I think that this have sence. What do you think?</p>
</p>
<p>Best Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Wed, 30 Jul 2008 05:41:23 +0300</pubDate>
        </item>
        <item>
        	<title>Creativebyte on Default options, multiselect, extend</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/default-options-multiselect-extend#p1323</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/default-options-multiselect-extend#p1323</guid>
        	        	<description><![CDATA[<p>Hi tony,</p>
<p>I got no problem since I don&#39;t overwrite the default array. All I do is to store all my jqgrid options for all grids I use in my app in a big array-structure and since you do a deep copy now everything works fine for me.</p>
]]></description>
        	        	<pubDate>Tue, 29 Jul 2008 14:01:50 +0300</pubDate>
        </item>
        <item>
        	<title>tony on Default options, multiselect, extend</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/default-options-multiselect-extend#p1318</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/default-options-multiselect-extend#p1318</guid>
        	        	<description><![CDATA[<p>But there is a big problem with this in your case:</p>
<p>$.extend($.jgrid.defaults,{rowList:[10,20,30]});</p>
<p>$("#mygrid").jqGrid({</p>
<p>.....</p>
<p>rowList: [],</p>
<p>..</p>
<p>});</p>
<p>rowList remain [10,20,30]</p>
<p>You can test this.</p>
<p>That means that the current settings of the grid are overwriten.</p>
<p>Maybe I will disable this in next release.</p>
]]></description>
        	        	<pubDate>Tue, 29 Jul 2008 09:39:55 +0300</pubDate>
        </item>
        <item>
        	<title>Creativebyte on Default options, multiselect, extend</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/default-options-multiselect-extend#p1260</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/default-options-multiselect-extend#p1260</guid>
        	        	<description><![CDATA[<p>Thanks a lot!</p>
]]></description>
        	        	<pubDate>Fri, 25 Jul 2008 11:29:03 +0300</pubDate>
        </item>
        <item>
        	<title>tony on Default options, multiselect, extend</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/default-options-multiselect-extend#p1222</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/default-options-multiselect-extend#p1222</guid>
        	        	<description><![CDATA[<p>Added in 3.2.1</p>
]]></description>
        	        	<pubDate>Wed, 23 Jul 2008 10:52:58 +0300</pubDate>
        </item>
        <item>
        	<title>Creativebyte on Default options, multiselect, extend</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/default-options-multiselect-extend#p1218</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/default-options-multiselect-extend#p1218</guid>
        	        	<description><![CDATA[<p>Hi Tony,</p>
<p>Neither did I, it took me a couple of days a going through raw jquery source code to know what&#39;s happening. As I said: I did the modification and it&#39;s working perfectly for me. The only difference in the extend behaviour is, that the complete object is really copied and not only the first level ("lower" levels are passed on by reference). jQuery sourcecode on this function is quite easy to read, if you do you will notice there is nothing to fear about.</p>
<p>I also did a quick snippet werwe you can see the effect:</p>
<p>&#60;html&#62;<br />&#160;&#160;&#160; &#60;head&#62;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#60;script type="text/javascript" src="jquery.js"&#62;&#60;/script&#62;<br />&#160;&#160;&#160; &#60;/head&#62;<br />&#160;&#160;&#160; &#60;body&#62;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#60;script type="text/javascript"&#62;<br />&#160;&#160;&#160; &#160;&#160;&#160; settings =&#160;&#160; { a:1, b:2, c:[1,2,3]};<br />&#160;&#160;&#160; &#160;&#160;&#160; def = { a:0, b:0, c:[0,0,0]};<br />&#160;&#160;&#160; &#160;&#160;&#160; <br />&#160;&#160;&#160; &#160;&#160;&#160; p = $.extend(def, settings &#124;&#124;{});<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; p.c[0] = 25;<br />&#160;&#160;&#160; &#160;&#160;&#160; <br />&#160;&#160;&#160; &#160;&#160;&#160; console.log(settings);<br />&#160;&#160;&#160; &#160;&#160;&#160; &#60;/script&#62;<br />&#160;&#160;&#160; &#60;/body&#62;<br />&#60;/html&#62;</p>
<p>If you call it like this, the settings object will me modified (c[0] will actually be 25 and not 0 like it should be). If you insert an boolean true as first parameter to extend, you will notice that the settings object remains untouched by operations on p (like it should be).</p>
<p>BR,</p>
<p>Creativebyte</p>
]]></description>
        	        	<pubDate>Wed, 23 Jul 2008 10:44:27 +0300</pubDate>
        </item>
        <item>
        	<title>tony on Default options, multiselect, extend</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/default-options-multiselect-extend#p1201</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/default-options-multiselect-extend#p1201</guid>
        	        	<description><![CDATA[<p>Creativebyte,</p>
<p>Thank you very much for this. To be a honest I do not known</p>
<p>of this feature of $.extend. I will add this, but before this I should</p>
<p>do some tests.</p>
<p>Thank you</p>
<p>Best Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Wed, 23 Jul 2008 03:09:08 +0300</pubDate>
        </item>
        <item>
        	<title>Creativebyte on Default options, multiselect, extend</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/default-options-multiselect-extend#p1194</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/default-options-multiselect-extend#p1194</guid>
        	        	<description><![CDATA[<p>Hi,</p>
<p>I use jqGrid in some table with multiselect. Since I tend to have everything that belongs together in data structures (which are msot of the time seperate files) I did the same with all my grid options. I did my setup in a way:</p>
<p>var gridoptions = {</p>
<p>&#39;grid_1&#39;: {url:...,datatype:...},<br />&#39;grid_2&#39;:{....}</p>
<p>}</p>
<p>The problem is: when I use multiselect and open the page again and again, new rows with checkboxes are added all the time. I did a lot of research on this and finally came up with the solution: When the default optiosn and the user options are merged, the function $.extend from jQuery is used. In a normal case, where you specify your options directly in the code (and not like in my case in a seperate data structure) this is fine. But I store everything in my structure, so $.extend manipulates my setup instead of doing it only jqGrid internal. I think it has something to do with my multi-level object structure, but anyway: there is a simple solution: $.extend has another first option, that can be set to true. If this is done (and this is quite well hidden in the documentation), not a simple copy of the data structure is done (which is causing my problems), but a deep copy is done, like a recursive copy. So when I modify the code to $.extend(true,....) everything is working fine.</p>
</p>
<p>Long story short: In future versions, please enable deep copy for extend, it keeps me from changing the code every time again when a new version is coming out.</p>
<p>Thank you!</p>
<p>Creativebyte</p>
]]></description>
        	        	<pubDate>Tue, 22 Jul 2008 16:10:57 +0300</pubDate>
        </item>
</channel>
</rss>