<?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: Multiple jqGrids -- Movable, Draggable, and Sizable</title>
	<link>http://www.trirand.com/blog/?page_id=393/discussion/multiple-jqgrids-movable-draggable-and-sizable</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/discussion/multiple-jqgrids-movable-draggable-and-sizable/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>agb on Multiple jqGrids -- Movable, Draggable, and Sizable</title>
        	<link>http://www.trirand.com/blog/?page_id=393/discussion/multiple-jqgrids-movable-draggable-and-sizable#p17726</link>
        	<category>Discussion</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/discussion/multiple-jqgrids-movable-draggable-and-sizable#p17726</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>this is exactly what the doctor prescribed. However, I am new to all this and I have difficulties to bring it all together. Any chance you could post a complete working example or demo link?</p>
<p>Thanks</p>
<p>Alex</p>
]]></description>
        	        	<pubDate>Fri, 04 Jun 2010 09:49:25 +0300</pubDate>
        </item>
        <item>
        	<title>tony on Multiple jqGrids -- Movable, Draggable, and Sizable</title>
        	<link>http://www.trirand.com/blog/?page_id=393/discussion/multiple-jqgrids-movable-draggable-and-sizable#p17578</link>
        	<category>Discussion</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/discussion/multiple-jqgrids-movable-draggable-and-sizable#p17578</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>First of all thank you very much for this lession and addition.</p>
<p>I&#39;m really surprised on this and will go to test it.</p>
<p>Also for the last "BIG PROBLEM"&#160; about zindex in delete dialog.</p>
<p>You can set the zindex of every modal dialog programatically.</p>
<p>In you case you will need just to add in delete dialog options:</p>
<p>zIndex : 1005.</p>
<p>Thanks again for this lession.</p>
</p>
<p>Best Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Sun, 30 May 2010 13:01:52 +0300</pubDate>
        </item>
        <item>
        	<title>squid on Multiple jqGrids -- Movable, Draggable, and Sizable</title>
        	<link>http://www.trirand.com/blog/?page_id=393/discussion/multiple-jqgrids-movable-draggable-and-sizable#p17385</link>
        	<category>Discussion</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/discussion/multiple-jqgrids-movable-draggable-and-sizable#p17385</guid>
        	        	<description><![CDATA[<p>So I&#39;ve been playing with jqGrid for the last several evenings and would like to share what I&#39;ve done in case others are interested in this feature.</p>
</p>
<p>EDIT: &#160;I removed my caution about not working with IE. &#160;This does appear to work with IE8 (at least).</p>
</p>
<p>I&#39;m building an application that has a standard style interface that allows a user to edit data; the data is a natural fit for a tree-grid view. &#160;However, the users should have the ability to have multiple windows open at the same time and should be able to switch between them like any normal windowing interface. &#160;At first I thought to put the jqGrid inside of a jQuery dialog &#8212; but it didn&#39;t really "look that good" (for lack of a better description). &#160;The problem was partially because the grid "IS" the whole document. &#160;It&#39;s the focal point for where editing is performed. &#160;Therefore, I decided that I would make the jqGrid the UI element that should be draggable, sizable, etc. &#160;At first I thought I could just add the jQuery ui-dialog class to the object and be done with it. &#160;This had other adverse side effects that manifested themselves in very odd behavior (which I&#39;m still researching). &#160;With that said, here&#39;s a solution I came up with.</p>
</p>
<p>First I had to fix what appeared to be a bug in the resize code of jqGrid (which I&#39;ve posted elsewhere). &#160;There&#39;s odd behavior where a thin blue line surrounds the grid when you minimize it (but only if you minimize it AFTER resizing it).</p>
</p>
<pre>//
// Make the grid resizable.
//
$(this).jqGrid(&#39;gridResize&#39;, {
	minWidth:   350,
	minHeight:  150,
	stop:
		function (grid, ev, ui) {
			//
			// There seems to be an issue with resizing the grid so I added
			// this code to remove the "height" style.
			//
			$(grid.srcElement).parent ().css ("height", null);
		}
});

</pre>
<p>Next challenge was making it so they could overlap once I was able to instantiate more than one grid. &#160;I did this with this style (notice my comment about WHY I picked a z-index of 1002):</p>
</p>
<pre>/*
 * Had to make the z-index 1002 because the resize handle on the jquery
 * windows seems to be at 1001... go figure.
 */
.ui-jqgrid-active {
	z-index: 1002;
}

</pre>
<p>Next, I needed a way to initialize information pertaining to a grid; but only ONCE. &#160;I wanted to encapsulate as MUCH information as possible inside of the actual jqGrid definition, but I was not able to find any type of "one-time-initialization" function that I could override. &#160;Therefore, I overloaded the gridComplete() function and added an attribute to the dialog to mark it as "initialized." &#160;This code is as follows:</p>
</p>
<pre>gridComplete:
function () {
  if ($(this).attr (&#39;initialized&#39;) == undefined) {
    $(this).attr (&#39;initialized&#39;, true);
  }
</pre>
</p>
<p>I needed to make the window draggable. &#160;I added this block of code to my initialization code:</p>
</p>
<pre>//
// Make the window draggable.
//
$(&#39;#gbox_&#39; + id).draggable ({
	handle:"div.ui-jqgrid-titlebar",
	start: function () {
		$(".ui-jqgrid").removeClass (&#39;ui-jqgrid-active&#39;);
		$(this).addClass (&#39;ui-jqgrid-active&#39;);
	}
}).click (function () {
		$(".ui-jqgrid").removeClass (&#39;ui-jqgrid-active&#39;);
		$(this).addClass (&#39;ui-jqgrid-active&#39;);
}).css (&#39;position&#39;, &#39;absolute&#39;);
</pre>
</p>
<p>I had to make the position absolute because it kept putting new grids at the bottom of the browser and continued to grow downward. &#160;Finally, I wanted to have a "close" button on the title bar. &#160;I wasn&#39;t able to find any particular "hooks" to provide this capability, so I fired up Firebug, plowed through the jqGrid code &#38; css, and came up with the following solution (also added to my one-time-initialization code block):</p>
</p>
<pre>temp = $("<a style="right: 16px;" href="#" target="_blank"></a>")
         .addClass(&#39;ui-jqgrid-titlebar-close HeaderButton&#39;)
         .click (function () {
           $(this).parents (&#39;.ui-jqgrid&#39;).remove ();
	 })
	 .hover(
	   function() {$(this).addClass(&#39;ui-state-hover&#39;);},
           function() {$(this).removeClass(&#39;ui-state-hover&#39;);}
         ).append ("<span class="ui-icon ui-icon-circle-close">&#160;</span>");
$(&#39;#gbox_&#39;+ id + &#39; .ui-jqgrid-title&#39;).before (temp);
</pre>
</p>
<p>Part of this code was "borrowed" from the jqGrid code that creates the minimize button. &#160;Finally, I wrapped up the code that actually instantiated the dialog into a javascript function such as:</p>
<p>function setupJQGrid (treeTabeId, treePagerId) {</p>
<p>&#160;&#160;&#8230; grid initialization &#8230;</p>
<p>}</p>
<p>gridId is the id of the table to wrap the jqGrid around. &#160;Then I put an anchor and a div on the page to create the dialog that looked like this:</p>
<p>&#160;&#160; &#160;&#60;div id="test"&#62;div&#60;/div&#62;&#160;&#160; &#160;&#60;a href="#" id="testGrid"&#62;Test&#60;/a&#62;</p>
<p> and the javascript to actually create the div.</p>
<pre>$(&#39;#testGrid&#39;).click (function () {
	var rnd = Math.floor(Math.random()*10001);
	$(&#39;#test&#39;).append (&#39;&#39;);
	setupJQGrid (&#39;treegrid&#39; + rnd, &#39;ptreegrid&#39; + rnd);
});
</pre>
</p>
<p>This function just created some random number to make SURE that every window had its own unique ids (thus avoiding namespace clashes).</p>
</p>
<p>VOILA! &#160;Worked perfectly! &#160;So I think I put all my steps here correctly. &#160;Ideally, I&#39;d still like to make the ui-dialog class trick work (as I described above). &#160;I&#39;m sure I&#39;m not taking something into account for it, but the exercise I went through to make this method work was very valuable in understanding some of the inner workings of how jqGrid functions. &#160;Of course, even WITH the ui-dialog class added to the grid, I would have to do the z-index trick because they would not overlap correctly.</p>
</p>
<p>Thanks for writing a really nice plugin.</p>
</p>
<p>EDIT:</p>
<p>Upon further testing, I had to make a couple minor changes. &#160;For one, I had to "deactivate" ALL opened jqGrid windows in my initialization code like this:</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;$(".ui-jqgrid").removeClass (&#39;ui-jqgrid-active&#39;);</p>
</p>
<p>Then I had to add the ui-jqgrid-active class to the newly opened one. &#160;I tacked onto the end of the code above that setup the draggable() feature. &#160;Just add this after .css (&#39;position&#39;, &#39;absolute&#39;):</p>
<p>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; .addClass (&#39;ui-jqgrid-active&#39;);</p>
</p>
<p>That fixes it up nicely. &#160;The major issue now has to do with deleting records. &#160;Because I had to force the window to be z-index of 1002, the dialog box for deleting now appears BEHIND the active window. &#160;Big problem. &#160;I may have to go back and change the z-index of the drag handle to be less than 1001 thus alleviating my original css hack to set the active window to z-index 1002.</p>
]]></description>
        	        	<pubDate>Fri, 21 May 2010 17:52:26 +0300</pubDate>
        </item>
</channel>
</rss>