<?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: File upload problem</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/file-upload-problem</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/file-upload-problem/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>KDA on File upload problem</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/file-upload-problem#p30030</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/file-upload-problem#p30030</guid>
        	        	<description><![CDATA[<p>Hi,</p>
<p>I&#39;ve been using jqgrid to manage data in my database quite successfully, but now I need to add a &#39;file&#39; field.</p>
<p>If I set the field as &#39;required&#39;, then I&#39;m getting a Javascript error when I &#39;save&#39; a new record:</p>
<p>Error: TypeError: val is undefined<br />Source File: <a href="https://lopc-dev-0831/LOPCapp/js/jquery/jqGrid/js/jquery.jqGrid.src.js" rel="nofollow" target="_blank">https://lopc-dev-0831/LOPCapp/js/jquery/jqGrid/js/jquery.jqGrid.src.js</a><br />Line: 6281</p>
<p>(I&#39;m using version 4.5.4)</p>
<p>This is in the function isEmpty - which makes sense.</p>
<p>Tracing back the stack, this is called from</p>
<p>checkValues (line 6329)</p>
<p>saveRow (line 9395)</p>
<p>jqGrid (line 747)</p>
<p>onClickButton (line 9799)</p>
</p>
<p>If I don&#39;t mark the field as &#39;required&#39; I get data posted back to my php server app, but the element in the $_POST variable that I would expect to contain the name of the file (so I can then use the AjaxUploader as explained elsewhere) is not defined either.</p>
</p>
<p>I&#39;m seeing similar behaviour from both inline editting and form editting.</p>
<p>The source of my page is below. It&#39;s the field modFilename that&#39;s giving the problem.</p>
<p>&#60;?xml version="1.0" encoding="ISO-8859-1"?&#62;<br />&#60;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&#62;<br />&#60;html xmlns="http://www.w3.org/1999/xhtml"&#62;<br />&#60;head&#62;<br />&#60;title&#62;LOPC Data Management - View data&#60;/title&#62;<br />&#60;meta http-equiv="Content-type" content="text/html;charset=ISO-8859-1" /&#62;&#60;link rel="stylesheet" type="text/css" href="../style/LOPC.css?v=650432440" /&#62;<br />&#60;script type="text/javascript" src="../js/jquery/jquery.js"&#62;&#60;/script&#62;<br />&#60;script type="text/javascript" src="../js/jquery/jquery-ui.custom.js"&#62;&#60;/script&#62;<br />&#60;script type="text/javascript" src="../js/jquery/jquery.cookie.js"&#62;&#60;/script&#62;<br />&#60;link rel="stylesheet" type="text/css" href="../style/jquery-ui-1.10.3.custom.css" /&#62;<br />&#60;link rel="stylesheet" type="text/css" href="../js/jquery/jqGrid/css/ui.jqgrid.css" /&#62;<br />&#60;style&#62;<br />.ui-jqgrid,<br />.ui-jqgrid .ui-jqgrid-view,<br />.ui-jqgrid .ui-jqgrid-pager,<br />.ui-jqgrid .ui-pg-input {<br />&#160;&#160;&#160; font-size: 12px;<br />}<br />&#60;/style&#62;<br />&#60;/head&#62;<br />&#60;body &#62;<br />&#60;span class="Header"&#62;User-defined Modules&#60;/span&#62;&#60;br/&#62;<br />&#60;script src="../js/jquery/jqGrid/js/i18n/grid.locale-en.js" type="text/javascript"&#62;&#60;/script&#62;<br />&#60;script src="../js/jquery/jqGrid/js/jquery.jqGrid.src.js" type="text/javascript"&#62;&#60;/script&#62;<br />&#60;table id="LOPCgridtable"&#62;<br />&#60;/table&#62;<br />&#60;div id="LOPCgridnavbar" width="200%"&#62;<br />&#60;/div&#62;<br />&#60;script type="text/javascript"&#62;<br />$(document).ready(function(){<br />var lastsel = -1;<br />var fileuploadfield = "modFilename";<br />function afterEdit(id, result) {<br />&#160;&#160;&#160; if (result.responseText.substring(0,3) != &#39;## &#39;) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; alert(&#39;Update successful: &#39; + result.responseText);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (fileuploadfield != &#39;&#39;) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; alert(&#39;Need to upload file for field &#39; + fileuploadfield);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160; &#160;&#160;&#160; &#160;$("#LOPCgridtable").trigger("reloadGrid");<br />&#160;&#160;&#160; } else {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; alert(&#39;Update failed: &#39; + result.responseText);<br />&#160;&#160;&#160; }<br />}<br />$("#LOPCgridtable").jqGrid({<br />&#160;&#160; &#160;datatype: "xml",<br />&#160;&#160; &#160;url: "/LOPCapp/data/displaylist.php",<br />&#160;&#160; &#160;mtype: "POST",<br />&#160;&#160; &#160;postData: {table: "tblModule"},<br />&#160;&#160; &#160;colNames: ["Name", "Filename", "Actions"],<br />&#160;&#160; &#160;colModel: [{name: "modName", index: "modName", editable: true, edittype: &#39;text&#39;, editrules: {required: true}, editoptions: {maxlength: 50}}<br />, {name: "modFilename", index: "modFilename", editable: true, hidden: false, width: 200, align: &#39;left&#39;, edittype: &#39;file&#39;, editoptions: {enctype: "multipart/form-data"}, editrules: {required: true, edithidden: false}}<br />, {name: "Actions", width: "100%"}],<br />&#160;&#160; &#160;pager: "#LOPCgridnavbar",<br />&#160;&#160; &#160;rowNum: 20,<br />&#160;&#160; &#160;rowList: [10,20,30,50,100],<br />&#160;&#160; &#160;altrows: true,<br />&#160;&#160; &#160;viewrecords: true,<br />&#160;&#160; &#160;caption: "",<br />&#160;&#160;&#160; shrinktofit: true,<br />&#160;&#160; &#160;height: "auto",<br />&#160;&#160;&#160; onSelectRow: function(id) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (id &#38;&#38; id !== lastsel &#38;&#38; lastsel != -1) $("LOPCgridtable").restoreRow(lastsel);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $("#LOPCgridtable_ilsave").removeClass(&#39;ui-state-disabled&#39;);&#160;&#160;&#160;&#160;&#160;&#160;&#160; $("#LOPCgridtable").editRow(id, true, null, null, "/LOPCapp/data/displaylist.php", {table: &#39;tblModule&#39;}, afterEdit, null, null);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; lastsel = id;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; },<br />&#160;&#160;&#160; editurl: "/LOPCapp/data/displaylist.php",<br />&#160;&#160;&#160; editData: {table: "tblModule"}<br />});<br />$("#LOPCgridtable").navGrid("#LOPCgridnavbar",<br />&#160;&#160;&#160; {view: false, edit: false, add: false, del: true, search: false, refresh: true},<br />&#160;&#160;&#160; {},<br />&#160;&#160;&#160; {},<br />&#160;&#160;&#160; { delData:<br />&#160;&#160; &#160;&#160;&#160; &#160;{table: "tblModule"},<br />&#160;&#160;&#160;&#160;&#160; afterSubmit: function (result, postdata) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (result.responseText.substring(0,3) != &#39;## &#39;) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; alert(result.responseText);<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160;&#160; $("#LOPCgridtable").trigger("reloadGrid");<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; } else {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; alert(&#39;Deletion failed: &#39; + result.responseText);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; return [true]&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160; }<br />);<br />$("#LOPCgridtable").inlineNav("#LOPCgridnavbar",<br />&#160;&#160;&#160; {view: false, edit: true, add: true, del: true, <br />&#160;&#160;&#160;&#160;&#160; editParams: { extraparam: {table: "tblModule"}, aftersavefunc: afterEdit},<br />&#160;&#160;&#160;&#160;&#160; addParams: { addRowParams: {extraparam: {table: "tblModule"}, aftersavefunc: afterEdit}}<br />&#160;&#160;&#160; });<br />$("#LOPCgridtable").gridResize ({minWidth: 900});<br />});<br />&#60;/script&#62;<br />&#60;/body&#62;<br />&#60;/html&#62;</p>
</p>
<p>Thanks for any help you can provide to solve this problem - which is really annoying me!</p>
</p>
<p>Kevin</p></p>
]]></description>
        	        	<pubDate>Sat, 28 Dec 2013 23:41:16 +0200</pubDate>
        </item>
</channel>
</rss>