Forum


04:06

Moderators
30/10/2007

Hello,
Maybe you will need to use onInitializeForm event to attach this feature.
Regards
Ton
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
17:34

09/11/2009

Ok, in onItinializeForm, I added the field of type "file". The form layout is correct.
in onclickSubmit, I supposed to get the value of this field and append it to the postdata.
<input id="fileupload" class="FormElement" type="file" name="fileupload" size="20"/>';
How to get the value ? I tried postdata.fileupload but this gives "undefined"
in beforeSubmit, I tried to get the value:
beforeSubmit: function (aData,formid)
{
alert(aData.fileupload); <---- this gives "undefined" Normal because the index doesn't exist ?!
...
I also tried $("#fileupload",formid).val() but this gives "undefined"
That was the first problem ...
The second problem is the coexistance between the url of editGridRow and the url of the $.ajaxfileupload plugin.
How to send the data of the form + the extra data with only one url ?
18:45

30/07/2009

I think you're going to have to turn it around, and post the grid data via ajaxfileupload.
So in your beforeSubmit function, you're going to have to copy the postdata to the file upload plugin, and the submit that.
Not sure which file uploader you're using. I've used the one from http://valums.com/ajax-upload/. With that you would just do:
uploader.setData(postdata);
uploader.submit();
But then you would need to prevent the grid from submitting your request too... there doesnt seem to be an easy way to do that. But you /could/ return [false, "OK"] from beforeSubmit. The problem with that is that the grid would put "OK" into the error field - so you would need to hide the error field immediately.
I think you could do that with a setTimeout at the end of your beforeSubmit.
so (untested, but probably close):
beforeSubmit : function(postdata,form) {
uploader.setData(postdata);
uploader.submit();
setTimeout(function() { $("#FormError",form).hide() },0);
return [false,"OK"];
}
Mark
20:07

09/11/2009

Mark,
Is it possible to see your solution ? mine doesn't work.
var upload;
...
onInitializeForm: function (formid)
{
var cppass = '<tr id="tr_fileupload" class="FormData" rowpos="4">';
cppass += '<td class="CaptionTD ui-widget-content">Photo</td>';
cppass += '<td class="DataTD ui-widget-content" style="white-space: pre;">';
cppass += ' <input id="fileupload" class="FormElement" type="file" name="fileupload" size="20"/>';
cppass += '</td></tr>';
$(cppass).insertAfter("#tr_sexe",formid);
upload = new AjaxUpload('#fileupload',{action: 'upload.php'});
}
...
beforeSubmit: function (aData,formid)
{
upload.setData(aData);
upload.submit();
return [true,''];
},
Most Users Ever Online: 715
Currently Online:
54 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66