c# - jQuery Datatable row links -


i've looked @ many other similar questions mine, haven't found 1 goal quite same. i'm getting rows datatable database using ado.net entity model in asp.net mvc4. want able click link on given row, , have link take me different datatable of rows different database table associated link row clicked on. data binds clicked link new datatable want see in hidden column in each row. i've figured out can data "mrender" function via indices correspond view model in full[] array.

i green @ both mvc , jquery, please bear me read code.

here view:

@using system.web.optimization  @{     viewbag.title = "showpeople"; }  <h2>showpeople</h2> <div id="example_wrapper" class="datatables_wrapper form-inline" role="grid">     <table border="0" class="table table-striped table-bordered datatable" id="people" aria-describedby="example_info">         <thead>             <tr role="row">                 <th class="sorting" role="columnheader" tabindex="0" rowspan="1" colspan="1" aria-controls="example">header1</th>                 <th class="sorting" role="columnheader" tabindex="0" rowspan="1" colspan="1" aria-controls="example">header2</th>                 <th class="sorting" role="columnheader" tabindex="0" rowspan="1" colspan="1" aria-controls="example">header3</th>                 <th class="sorting" role="columnheader" tabindex="0" rowspan="1" colspan="1" aria-controls="example">header4</th>                 <th class="sorting" role="columnheader" tabindex="0" rowspan="1" colspan="1" aria-controls="example">header5</th>                 <th class="sorting" role="columnheader" tabindex="0" rowspan="1" colspan="1" aria-controls="example">header6</th>                 <th class="sorting" role="columnheader" tabindex="0" rowspan="1" colspan="1" aria-controls="example">header7</th>                 <th class="sorting" role="columnheader" tabindex="0" rowspan="1" colspan="1" aria-controls="example">header8</th>                 <th class="sorting" role="columnheader" tabindex="0" rowspan="1" colspan="1" aria-controls="example">header9</th>                 <th class="sorting" role="columnheader" tabindex="0" rowspan="1" colspan="1" aria-controls="example">header10</th>                 <th role="columnheader" tabindex="0" rowspan="1" colspan="1" aria-controls="example">id_part1</th>                 <th role="columnheader" tabindex="0" rowspan="1" colspan="1" aria-controls="example">id_part2</th>                 <th role="columnheader" tabindex="0" rowspan="1" colspan="1" aria-controls="example">links</th>             </tr>         </thead>         <tbody role="alert" aria-live="polite" aria-relevant="all"></tbody>     </table> </div> <script type="text/javascript">     $(document).ready(function () {         $('#people').datatable({             "bserverside": true,             "sajaxsource": "dataajaxhandler",             "bprocessing": true,             "spaginationtype": "full_numbers",             "aocolumns": [                             { "sname": "data1" },                             { "sname": "data2" },                             { "sname": "data3" },                             { "sname": "data4" },                             { "sname": "data5" },                             { "sname": "data6" },                             { "sname": "data7" },                             { "sname": "data8" },                             { "sname": "data9" },                             { "sname": "data10" },                             {                                 "sname": "id_one",                                 "bvisible": false,                                 "bsearchable": false,                                 "bsortable": false,                                 "mdata": null                             },                             {                                 "sname": "id_two",                                 "bvisible": false,                                 "bsearchable": false,                                 "bsortable": false,                                 "mdata": null                             },                             {                                 "sname": "links",                                 "bsortable": false,                                 "bsearchable": false,                                 "mdata": null,                                 "mrender": function (data, type, full) {                                     var urlbase = "@url.action("showdata", "data")";                                      return "<a href='" + urlbase + "/?id1=" + full[10] + "&id2=" + full[11] + "'>events</a>";                                 }                             }             ]         });     }); </script> 

here controller:

using system; using system.collections.generic; using system.linq; using system.web; using system.web.mvc; using web_ui.models;  namespace web_ui.controllers {     public class datacontroller : controller     {         //         // get: /reports/          public actionresult showdata()         {             return view();         }          public actionresult dataajaxhandler(jquerydatatableparammodel param)         {             //how can ids?         }     } } 

what i'm trying figure out if there way data hidden id columns controller's ajaxhandler action method. know how data need database using linq, need data id columns specific row link clicked it. there way can accomplish this?

many of questions i've read through involve pushing data "fnserverparams" function, don't understand how works , examples i've seen static (as in push same data). code provides url links right doesn't exercise in figuring out how access data hidden columns. edit: although said link urls don't go anywhere, didn't mean imply full[10] , full[11] aren't getting right values. i've checked urls code generates , indeed correct id numbers each row. don't know how pass them server use in controller.

thanks in advance help.

for sending data controller should use ajax call.

$.ajax({      url: "@(url.action("action", "controller"))",      type: "post",      cache: false,      async: true,      data: { id: 'id' },      success: function (result) {          (do something)      } }); 

you can pass multiple fields through data data: 'data, data1: 'data1', etc


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -