Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8610765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:12:19+00:00 2026-06-12T04:12:19+00:00

I have two datatables, one which lists foldes, and another which list’s files within

  • 0

I have two datatables, one which lists foldes, and another which list’s files within their parent folder. Here is how my script looks for the 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 the link I need to be able to pass that parentid to the file datatable. I have had no luck thus far. Here is how the JSON result looks in my controller, for the files datatable:

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 would I go about getting the link in the folder table to pass the parentid to the jsonresult for the file’s datatable successfully?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T04:12:20+00:00Added an answer on June 12, 2026 at 4:12 am

    I assume the dataTables are on the same page so I’d switch it to a button…

    "fnRender": function (oObj) {
        return '<button type="button" class="folder-view" data-id="' + oObj.aData[0] + '">View</button>';
    }
    

    Add a live click handler so you can set the current parentid and refresh the files dataTable. Handler might look like this…

    $('.folder-view').on('click', function() {
        var $filesTable = $('#filesTable');
        $filesTable.attr('data-parentid', $(this).attr('data-id'));
        //refresh the files table
        $filesTable.dataTable().fnDraw(false);
    });
    

    Finally, the files dataTable will need to override the fnServerData function to merge the extra parentid data…

    "fnServerData": function (sSource, aoData, fnCallback) {
    
        var extraData = [ { parentid: $('#filesTable').attr('data-parentid') } ];
    
        $.ajax({
            "dataType": "json",
            "type": "POST",
            "url": sSource,
            "data": $.merge(extraData, aoData),
            "success": fnCallback
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two datatables. One is to display names. Another contains three <h:selectOneMenu> .
i have two DataTables one with a hughe List of Results and one with
i have windows application in which i am constructing dataset with two datatables one
I have two DataTables one is Primary Table and the rest is a sub
I have two very similar usecases, one works, and another one does not. I
i have two data tables with the same structure the first one has one
I have two datatables. Each has three columns, the two of them have the
I have two datatables and I need to match zipcodes from each of the
I have two DataTables. First is DataTable NameAddressPhones = new DataTable(); with Three columns
if i have two datatables : DT1 & DT2 How to check if the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.