I have two types of data, one of which contains addition lists, and the other a list of files in the parent folder. This is how my script looks for a folder table:
var oTable = $('#folderTable').dataTable({ "bServerSide": true, "sAjaxSource": "AJAXViewFolders", "bProcessing": true, "bFilter": false, "aoColumns": [ { "sName": "folder_id", "bSearchable": false, "bSortable": false, "fnRender": function (oObj) { return '<a href=\"ViewFiles?parentid=' + oObj.aData[0] + '\">View</a>'; } }, { "sName": "folder_name" }, { "sName": "create_date" } ] }); });
Now, when the user clicks on the link, I need to transfer this parent to the datatable file. I still have no luck. This is how the JSON result looks in my controller, for datatable files:
public JsonResult AJAXViewFiles(DataTableParamModel dtParams, int parentid) { var repo = new TrusteeDocumentRepository(); var allDocuments = repo.FindAllFiles().Where(c=>c.folder_id == parentid); IEnumerable<Files> filteredFiles; filteredFiles = allDocuments; var displayedFiles = filteredFiles.Skip(dtParams.iDisplayStart).Take(dtParams.iDisplayLength); var result = from c in displayedFiles select new[] { Convert.ToString(c.folder_id),c.file_name, c.upload_date.ToString() }; return Json(new { sEcho = dtParams.sEcho, iTotalRecords = allDocuments.Count(), iTotalDisplayRecords = filteredFiles.Count(), aaData = result }, JsonRequestBehavior.AllowGet); }
How can I get the link in the folder table to pass the parent to jsonresult for the datatable file successfully?
source share