Page 1 of 1

upload file & related data shows in grid

Posted: Thu Jul 25, 2019 8:53 am
by amithatle123
Hi,

We want to show data in grid when we upload the pdf file which is stored in one location.
file name and Case Title (case number) both are same.
First upload the pdf file then all data shows in grid . example Case Title, Senders Ref. No. , BICCode
I have attached the image

Re: upload file & related data shows in grid

Posted: Thu Jul 25, 2019 9:32 pm
by amosbatto
Is the information that you need in the filename of the uploaded file?

I created a programming example for you:
https://www.pmusers.com/index.php/Set_g ... d_filename

Re: upload file & related data shows in grid

Posted: Thu Aug 01, 2019 9:26 am
by amithatle123
Hi,

One more question,
When I click on "+ new", If I upload the duplicate file then I want to popup message like "file is duplicate" on click on submit button & also want to delete this file.

&

As previous Reply,
When I upload the file, File name stored in "app_document" and Case Title stored in "app_cache_view" which I want to show in the Grid.
The "File name" & "Case Title" both are same "name" which I want to show in the Grid.

Please Help
Thank You

Re: upload file & related data shows in grid

Posted: Sat Aug 03, 2019 12:53 am
by amosbatto
amithatle123 wrote: Thu Aug 01, 2019 9:26 am One more question,
When I click on "+ new", If I upload the duplicate file then I want to popup message like "file is duplicate" on click on submit button & also want to delete this file.
You can use this JavaScript code in the example Dynaform that I gave you:
Code: Select all
//change to the ID of the grid:
var gridId = "productsList";
//set to ID of the File field in grid:
var gridFileId = 'productFile';

var reFileInGrid = new RegExp("^\\["+gridId+"\\]\\[(\\d+)\\]\\["+gridFileId+"\\]$");
var formId = $("form").prop("id");

$("#"+formId).setOnchange( function(fieldId, filename, oldValue) {
  var aMatch = fieldId.match(reFileInGrid);
  
  //if the "productFile" field was changed in the "productsList" grid:
  if (aMatch) {
    var rowNo = aMatch[1];
    var basename = filename;
    
    if (filename.lastIndexOf(".") != -1) {       
      basename = filename.substring(0, filename.lastIndexOf("."));
    }
    
    //Search for duplicate filenames that have been uploaded in the same grid.
    //If a duplicate is found, then delete this file and display an alert message 
    //to the user saying that duplicate filenames are not allowed.
    var oGrid = $("#"+gridId);
    var nRows = oGrid.getNumberRows();
    
    
    for (var i = 1; i <= nRows; i++) {
      var fileFieldId = "form["+gridId+"]["+i+"]["+gridFileId+"]";
      var oFileButton = $("[id='"+fileFieldId+"']").parent().find("button");
      var filenameInRow = oFileButton.text();
     
      if (i != rowNo && filenameInRow != '' && filename == filenameInRow) {
        alert("The file '"+filename+"' has already been uploaded in row "+i+".\n"+
              "Duplicate files are not allowed.");
        
        //remove filename from File's button:
    	$("[id='"+"form"+fieldId+"']").parent().find("button").text("Allowed file extensions: *"); 
    	$("[id='"+"form"+fieldId+"']").val('');       //clear hidden file input field
    	$("[id='"+"form"+fieldId+"_label']").val(''); //clear filename in hidden text field
      }
    }
    
    //set the file's basename in the "productName" field for the same grid row:
    $("#productsList").setValue(basename, rowNo, 1);
    
  } 
});

Re: upload file & related data shows in grid

Posted: Sat Aug 03, 2019 1:01 am
by amosbatto