1

I have done FileUpload using Handler in Jqgrid. When i click "ADD" i can able to browse the file and able to upload the value.

enter image description here

But now if i want to edit the same path, when i click on "EDIT" it is not bringing the already browsed file.

URL Value is empty

below is the colmodel:

{
    
   name: 'FormPath', index: 'FormPath', editable: true, width: 50, edittype: 'file',                                          
   editoptions: 
   {  
      enctype: "multipart/form-data"
   },
   formatter: function (cellvalue, options, rowObject)
   {
      return '<a href="' + cellvalue + '">' + rowObject.FormDisplayName + '</a>';
   },
   unformat: function (cellvalue, options, cell)
   {
       return $('a', cell).attr('href');
   }
}

Below is the beforeshowForm event where i called in Form_edit dialog. other controls are binding correct data. But this FormPath is not.

beforeShowForm: function (form) 
{
    $("#FormError").remove();
    $("#tr_FormDisplayName", form).show();
    $("#tr_FormPath", form).show();
    $('#tr_FormDesc', form).show();
    $('#tr_SecurityTag', form).show();
}

Anybody have any idea how do i populate the unformatted the value into the cell in edit dialog box in jqgrid.

Thanks in advance.

Parthhu
  • 67
  • 1
  • 8
  • I can able to get the value using var catFormPath = $("#" + subgrid_table_id).jqGrid('getCell', selRowId, 'FormPath'); . But this is returning only old value. I have tried to setup this old value in beforeShowForm event to FormPath. But that too failed to setup. @oleg – Parthhu Feb 10 '15 at 10:53
  • if you want to write a message to me you should write comment on some **old** question or answer where I posted something (at least a comment). You current above comment didn't bring me any notification. Moreover you should better modify the text of your question (click "edit" link below the text of the question) and append it to all information which is important to understand of your problem. – Oleg Feb 10 '15 at 12:12
  • Thanks @Oleg. Is my question understandable ? . I can upload file using "ADD" . Now the problem with "EDIT" . i want to auto populate the uploaded file path in the edit dialog box. Hope it should bring it. But it is not happening. – Parthhu Feb 10 '15 at 12:20
  • @Oleg, modified the question now. Hope it is more understandable now. – Parthhu Feb 10 '15 at 12:31
  • I tried to explain in my answer that the behavior which you see is **correct**. It should not exist any workaround. If you will do find a way then you should post it to developers of the corresponding web browsers and the *bug* will be quickly fixed. – Oleg Feb 10 '15 at 13:22

1 Answers1

0

It seems to me that you want to fill input value of

<input type="file" ... />

but it's not possible (on my information) because of security reasons. See the answer for example.

By the way jqGrid don't have any built-in support for file upload. So you have to use some additional plugins (something like Plupload) or to write relatively long code. In any way you will be not able to "pre-fill" <input type="file"/> with input data.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Hi @oleg, Thanks for your response. If you refer my previous question and answer i posted it let you know how i uploaded the file [link]http://stackoverflow.com/q/28212260/4324106 – Parthhu Feb 10 '15 at 12:17
  • @Parthhu: The problem is not the posting of the data to the server (sending of binary data to the server). The problem is that you can't fill "pre-fill" ``. If it would be possible that one could immediately include `submit` in the JavaScript code so it would be possible to upload any data from the computer of any user. One need just to know the path to the corresponding file. So "pre-fill" of `` is **explicitly prohibited in all web browsers**. – Oleg Feb 10 '15 at 13:19
  • Thanks a lot @oleg. let me try to add some label near to file upload control to show the value. – Parthhu Feb 11 '15 at 09:21
  • @Parthhu: You are welcome! You can use [formoptions](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:common_rules#formoptions) to set label, suffix or prefix or/and add `title` (tooltip) on the `` in Edit dialog, which describes the reason why the old values could not be inserted in the control. – Oleg Feb 11 '15 at 09:45
  • Yes. I done like this. Referred in your old post. really helpful for me. `var nameColumnField = $('#tr_FormPath', form).show();` `$('Additional Information:' + $("#" + subgrid_table_id).jqGrid('getCell', 1, 'FormPath') + ' ').insertAfter(nameColumnField);` **Now i can atleast show the user what path he selected previously. Only facing control width problems. Hope i will fix that too** @Oleg – Parthhu Feb 11 '15 at 11:37
  • Any suggestions for me for this post [post](http://stackoverflow.com/q/28577354/4324106) @oleg. – Parthhu Feb 18 '15 at 06:30