<?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: Changing Format before save</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/changing-format-before-save</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/help/changing-format-before-save/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>tony on Changing Format before save</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/changing-format-before-save#p8405</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/changing-format-before-save#p8405</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>This example is very helpfull.</p>
<p>OK - the problem - Which is the first chicken or the egg.</p>
<p>In order to understand what is happen:</p>
<p>1. You format the hour (represented as number) and this work ok.</p>
<p>2. You try to edit the formated data, but before to display it you make a unformat. (When we edit the data the first what we do is to unformat it).</p>
<p>3. You have the unformated data.</p>
<p>4. After unformat we applay all the events - including dataInit where you apply the mask plugin, but this data is alredy number and it can not be used correctly in the plugin.</p>
<p>5. The result - inconsitent display.</p>
</p>
<p>I think that in this case you should not the unformat, but rather use some events in cellEditing to post the number and then this number will be correcly converted from format function.</p>
</p>
<p>If you have difficulties please let me know.</p>
</p>
<p>Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Mon, 10 Aug 2009 05:32:57 +0300</pubDate>
        </item>
        <item>
        	<title>Romyn on Changing Format before save</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/changing-format-before-save#p8373</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/changing-format-before-save#p8373</guid>
        	        	<description><![CDATA[<p>I&#39;ll admit to being pretty confused myself now.</p>
</p>
<p>I&#39;ve downloaded the latest GitHub files and made the changes to how the functions are defined - (don&#39;t know where the var versions came from - must have been done that way in the examples I used).</p>
</p>
<p>Anyway with those changes made I&#39;m still having some trouble. The ideal scenario I want to get to is to store as Seconds, display as HH:MM:SS and edit using a Mask in the for __:__:__</p>
</p>
<p>To that end I&#39;ve put together a simple page with a grid that has various differently configured columns - and celleditting enabled so just clicking in and out of the cell should show the effects.</p>
<p><a href="http://www.thekmz.co.uk/GEPlugin/wip/test/gridtest4/gridtest4.htm" rel="nofollow" target="_blank"><a href="http://www.thekmz.co.uk/GEPlug" rel="nofollow">http://www.thekmz.co.uk/GEPlug</a>.....dtest4.htm</a></p>
</p>
<p>Simple - no formatting at all</p>
<p>fmt - just the formatter</p>
<p>fmt/unfmt - formatter and unformatter</p>
<p>fmt/mask - formatter and mask</p>
<p>fmt/unfmt/mask - formatter, unformatter and mask</p>
</p>
<p>The fmt/unfmt column works as designed (except when the value is 0 which I can&#39;t suss out?) - but I want to then add the mask to that but that doesn&#39;t seem to work. I also appreciate that some of the columns shouldn&#39;t work correctly but they are there just to show how I build up through adding the various options)</p>
</p>
<p>(also tried the var myval = $(cellval).html(); thing you mentioned but that didn&#39;t work for me at all so I went back to the old style).</p>
</p>
<p>Sorry this is so confused but it reflects the state of my little brain...</p>
<p>(I might be better off going back to storing the value as a HH:MM:SS string but I want to avoid that if I can)</p>
</p>
<p>Regards</p>
<p>Romyn</p></p>
]]></description>
        	        	<pubDate>Fri, 07 Aug 2009 13:14:10 +0300</pubDate>
        </item>
        <item>
        	<title>tony on Changing Format before save</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/changing-format-before-save#p8348</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/changing-format-before-save#p8348</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>I made the needed fixes in the GitHub. Also fixed some other bugs related for datetype as function</p>
<p>Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Fri, 07 Aug 2009 00:09:41 +0300</pubDate>
        </item>
        <item>
        	<title>tony on Changing Format before save</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/changing-format-before-save#p8327</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/changing-format-before-save#p8327</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>Here is the problem: (instead I found another in formedit regrading this)</p>
<p>You define the&#160; fmt_HMS</p>
<p>as var fmt_HMS = function&#8230;.</p>
<p>Which I think it is after the grid</p>
<p>To work this you should</p>
<p>1. Define this variable before the grid</p>
<p>2. or define the function as follow:</p>
<p>function fmt_HMS (&#8230;) {</p>
<p>&#8230;</p>
<p>}</p>
<p>and not var fmt_HMS = function.</p>
</p>
<p>Also there is a bug into the documentation</p>
<p>The cellvall parameter is a jQuery object, but not a value</p>
<p>with other words you should</p>
<p>function fmt_HMS (cellval, options) {</p>
<p>var myval = $(cellval).html();</p>
<p>// do something with this and</p>
<p>&#8230;</p>
<p>return newvalue;</p>
<p>}</p>
<p><strong> BUT THIS WIIL BE CHANGED IN ORDER TO HAVE EQUAL STANDART PARMETERS&#160; IN BOTH FORMAT AND UNFORMAT FUNCTIONS<br /></strong></p>
<p>Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Thu, 06 Aug 2009 12:30:01 +0300</pubDate>
        </item>
        <item>
        	<title>tony on Changing Format before save</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/changing-format-before-save#p8326</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/changing-format-before-save#p8326</guid>
        	        	<description><![CDATA[<p>Hello again,</p>
<p>Tottaly confused. It is a my fault at all. All will be fixed in the 3.5.1 and documented&#160; again - found the problem.</p>
<p>Also What is the problem with treeGrid?</p>
<p>Thanks</p>
<p>Best Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Thu, 06 Aug 2009 12:19:19 +0300</pubDate>
        </item>
        <item>
        	<title>Romyn on Changing Format before save</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/changing-format-before-save#p8325</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/changing-format-before-save#p8325</guid>
        	        	<description><![CDATA[<p>I&#39;ve just downloaded the latest pack again (not the GitHub one) and it is different so I&#39;m not completely up-to-date on that by the looks of things.</p>
</p>
<p>However using the latest a TreeGrid I have gets stuck on &#8220;Loading&#8221; so something has changed in that that I need to fix first &#8211; new syntax or something?</p>
</p>
<p>I&#39;ll try and do that and then see if the unformat function gets called. (Can&#39;t get to it until I fix the TreeGrid as that is the launch point for the other grids with the meat in them)</p>
</p>
<p>Regards</p>
<p>Romyn</p>
</p>
<p>edit - just seen your other reply. Thx - I&#39;ll download again in a few days.</p>
]]></description>
        	        	<pubDate>Thu, 06 Aug 2009 12:06:29 +0300</pubDate>
        </item>
        <item>
        	<title>tony on Changing Format before save</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/changing-format-before-save#p8324</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/changing-format-before-save#p8324</guid>
        	        	<description><![CDATA[<p>Hello Romyn,</p>
<p>Thanks - it is a bug in formedit module. Fixed. Will publish a bug fix release at end of this week.</p>
<p>Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Thu, 06 Aug 2009 12:04:32 +0300</pubDate>
        </item>
        <item>
        	<title>Romyn on Changing Format before save</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/changing-format-before-save#p8320</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/changing-format-before-save#p8320</guid>
        	        	<description><![CDATA[<p>Hi,</p>
</p>
<p>The relevant bits are:-</p>
</p>
<p><strong>The col model:</strong></p>
<p>{name:&#39;sdelay&#39;, index:&#39;sdelay&#39;, width:60, align:&#39;center&#39;,editable:true, editoptions:{dataInit:function(el){$(el).mask(&#8221;99:99:99&#8243;);}, defaultValue:&#39;00:00:00&#39;}, formatter: fmt_HMS, unformat: unfmt_HMS},</p>
</p>
<p><strong>The format function:</strong></p>
<p>var fmt_HMS = function(cellval,options,rowdata) {<br />&#160;&#160;&#160; formatted_cellval = secsToHMS(cellval);<br />&#160;&#160;&#160; return formatted_cellval;<br />}</p>
</p>
<p><strong>The unformat function:</strong></p>
<p>var unfmt_HMS = function(cellval,options) {<br />&#160;&#160;&#160; unformatted_cellval = HMSToSecs(cellval);<br />&#160;&#160;&#160; return unformatted_cellval;<br />}</p>
</p>
<p><strong>Support functions:</strong></p>
<p>function HMSToSecs(duration) {<br />&#160;&#160;&#160; var d_array = duration.split(&#8221;:&#8221;); <br />&#160;&#160;&#160; var s = (parseInt(d_array[0],10)*3600) + (parseInt(d_array[1],10)*60) + parseFloat(d_array[2]);<br />&#160;&#160;&#160; return s;<br />}</p>
</p>
<p>function secsToHMS(secs) {<br />var h = parseInt(secs/3600,10);<br />var m = parseInt((secs-(3600*h))/60,10);<br />var s = parseInt((secs-(3600*h)-(60*m)),10);<br />var hms = PadDigits(h,2) + &#39;:&#39; + PadDigits(m,2) + &#39;:&#39; + PadDigits(s,2);<br />return hms;<br />}</p>
</p>
<p>PadDigits just adds leading 0&#39;s when needed &#8211; and the .mask is a masked edit plugin.</p>
<p>I believe I&#39;m running the last version for which a min&#39;ed pack was available &#8211; not the latest from GitHub &#8211; it doesn&#39;t even get into the unformat function (an alert in there doesn&#39;t fire) so this could be why.</p>
</p>
<p>Romyn</p>
]]></description>
        	        	<pubDate>Thu, 06 Aug 2009 11:41:48 +0300</pubDate>
        </item>
        <item>
        	<title>tony on Changing Format before save</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/changing-format-before-save#p8318</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/changing-format-before-save#p8318</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>Could you post the code for the format and unformat functions - or better post all again with grid configuration.</p>
]]></description>
        	        	<pubDate>Thu, 06 Aug 2009 11:18:01 +0300</pubDate>
        </item>
        <item>
        	<title>Romyn on Changing Format before save</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/changing-format-before-save#p8316</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/changing-format-before-save#p8316</guid>
        	        	<description><![CDATA[<p>Thanks Tony,</p>
</p>
<p>That looks to be just the job. I tried it quickly but couldn&#39;t get it to work - what version to I need to be running for this?</p>
</p>
<p>Cheers</p>
<p>Romyn</p>
]]></description>
        	        	<pubDate>Thu, 06 Aug 2009 11:08:16 +0300</pubDate>
        </item>
        <item>
        	<title>tony on Changing Format before save</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/changing-format-before-save#p8311</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/changing-format-before-save#p8311</guid>
        	        	<description><![CDATA[<p><a href="http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_formatter#unformatting" rel="nofollow" target="_blank"><a href="http://www.trirand.com/jqgridw" rel="nofollow">http://www.trirand.com/jqgridw</a>.....formatting</a></p>
]]></description>
        	        	<pubDate>Thu, 06 Aug 2009 10:57:12 +0300</pubDate>
        </item>
        <item>
        	<title>Romyn on Changing Format before save</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/changing-format-before-save#p8310</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/changing-format-before-save#p8310</guid>
        	        	<description><![CDATA[<p>Hi,</p>
</p>
<p>I had a search and looked through the new wiki - I take it it&#39;s new anyway - very nice! - but am a bit confused to what I should being doing to perform the following.</p>
</p>
<p>I have a number of columns/cells whose value is held in seconds but displayed as either HH:MM:SS or MM:SS. This works fine on the display side using a couple of custom formatters but the problem comes when I try and add/edit (both inline and via dialog form).</p>
</p>
<p>I don&#39;t know how to take the input which is a string and convert that into an integer. I have the functions to do the conversions but I don&#39;t know where/how to apply them. How/where do I grab the value and change it in the celledit, addnew and edit forms.</p>
<p>I&#39;m sure this is pretty strightforward but would really appreciate some pointers.</p>
</p>
<p>Thanks and regards</p>
<p>Romyn</p>
]]></description>
        	        	<pubDate>Thu, 06 Aug 2009 10:51:13 +0300</pubDate>
        </item>
</channel>
</rss>