Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
jqgrid and the ajax_upload plugin
25/11/2009
05:37
Avatar
phicarre
Member
Members
Forum Posts: 132
Member Since:
09/11/2009
sp_UserOfflineSmall Offline

Tony suggests to use another plugin for the file uploading.

e.g: ajax_upload

I didn't find how to use it in form editing.

Any helps ?

27/11/2009
04:06
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

27/11/2009
12:01
Avatar
phicarre
Member
Members
Forum Posts: 132
Member Since:
09/11/2009
sp_UserOfflineSmall Offline

The problem is to implement it with other fields in the same form …

But I think I understood with your answer about "not defined field". I'll try

27/11/2009
17:34
Avatar
phicarre
Member
Members
Forum Posts: 132
Member Since:
09/11/2009
sp_UserOfflineSmall Offline

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 ?

27/11/2009
18:45
Avatar
markw65
Member
Members
Forum Posts: 179
Member Since:
30/07/2009
sp_UserOfflineSmall Offline

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

28/11/2009
20:07
Avatar
phicarre
Member
Members
Forum Posts: 132
Member Since:
09/11/2009
sp_UserOfflineSmall Offline

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,''];
                    },

Forum Timezone: Europe/Sofia

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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information