This article shows how an expandable master-details table can be implemented in ASP.NET MVC using the jQuery DataTables plug-in.
- JQueryMasterDetailsDataTables.zip
- JQueryMasterDetailsDataTables
- bin
- JQueryMasterDetailsDataTables.dll
- Content
- dataTables
- images
- back_disabled.jpg
- back_enabled.jpg
- details_close.png
- details_open.png
- favicon.ico
- forward_disabled.jpg
- forward_enabled.jpg
- sort_asc.png
- sort_asc_disabled.png
- sort_both.png
- sort_desc.png
- sort_desc_disabled.png
- Sorting icons.psd
- themes
- base
- images
- ui-bg_flat_0_aaaaaa_40x100.png
- ui-bg_flat_75_ffffff_40x100.png
- ui-bg_glass_55_fbf9ee_1x400.png
- ui-bg_glass_65_ffffff_1x400.png
- ui-bg_glass_75_dadada_1x400.png
- ui-bg_glass_75_e6e6e6_1x400.png
- ui-bg_glass_95_fef1ec_1x400.png
- ui-bg_highlight-soft_75_cccccc_1x100.png
- ui-icons_222222_256x240.png
- ui-icons_2e83ff_256x240.png
- ui-icons_454545_256x240.png
- ui-icons_888888_256x240.png
- ui-icons_cd0a0a_256x240.png
- jquery-ui.css
- smoothness
- images
- ui-bg_flat_0_aaaaaa_40x100.png
- ui-bg_flat_75_ffffff_40x100.png
- ui-bg_glass_55_fbf9ee_1x400.png
- ui-bg_glass_65_ffffff_1x400.png
- ui-bg_glass_75_dadada_1x400.png
- ui-bg_glass_75_e6e6e6_1x400.png
- ui-bg_glass_95_fef1ec_1x400.png
- ui-bg_highlight-soft_75_cccccc_1x100.png
- ui-icons_222222_256x240.png
- ui-icons_2e83ff_256x240.png
- ui-icons_454545_256x240.png
- ui-icons_888888_256x240.png
- ui-icons_cd0a0a_256x240.png
- jquery-ui-1.7.2.custom.css
- Controllers
- Global.asax
- Global.asax.cs
- JQueryMasterDetailsDataTables.csproj
- JQueryMasterDetailsDataTables.csproj.user
- Models
- obj
- Debug
- TempPE
- Properties
- Scripts
- Views
- Web.config
- Web.Debug.config
- Web.Release.config
|
@{
Layout = "~/Views/Home/MasterDetailsLayoutPage.cshtml";
}
@section onReady{
var oTable;
$('#companies tbody td img').click(function () {
var nTr = this.parentNode.parentNode;
if (this.src.match('details_close')) {
/* This row is already open - close it */
this.src = "/Content/images/details_open.png";
oTable.fnClose(nTr);
}
else {
/* Open this row */
this.src = "/Content/images/details_close.png";
var companyid = $(this).attr("rel");
$.get("CompanyEmployees?CompanyID=" + companyid, function (employees) {
oTable.fnOpen(nTr, employees, 'details');
});
}
});
/* Initialize table and make first column non-sortable*/
oTable = $('#companies').dataTable({ "bJQueryUI": true,
"aoColumns": [
{ "bSortable": false, "bSearchable": false },
null,
null,
null
]
});
}
<div id="demo">
<table id="companies" class="display">
<thead>
<tr>
<th></th>
<th>Company name</th>
<th>Address</th>
<th>Town</th>
</tr>
</thead>
<tbody>
<tr>
<td><img src="/Content/images/details_open.png" rel="0" alt="expand/collapse"></td>
<td>Emkay Entertainments</td>
<td>Nobel House, Regent Centre</td>
<td>Lothian</td>
</tr>
<tr>
<td><img src="/Content/images/details_open.png" rel="0" alt="expand/collapse"></td>
<td>The Empire</td>
<td>Milton Keynes Leisure Plaza</td>
<td>Buckinghamshire</td>
</tr>
<tr>
<td><img src="/Content/images/details_open.png" rel="2" alt="expand/collapse"></td>
<td>Asadul Ltd</td>
<td>Hophouse</td>
<td>Essex</td>
</tr>
<tr>
<td><img src="/Content/images/details_open.png" rel="3" alt="expand/collapse"></td>
<td>Ashley Mark Publishing Company</td>
<td>1-2 Vance Court</td>
<td>Tyne & Wear</td>
</tr>
<tr>
<td><img src="/Content/images/details_open.png" rel="4" alt="expand/collapse"></td>
<td>MuchMoreMusic Studios</td>
<td>Unit 29</td>
<td>London</td>
</tr>
<tr>
<td><img src="/Content/images/details_open.png" rel="5" alt="expand/collapse"></td>
<td>Audio Records Studios</td>
<td>Oxford Street</td>
<td>London</td>
</tr>
</tbody>
</table>
</div>
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Graduated from Faculty of Electrical Engineering, Department of Computer Techniques and Informatics, University of Belgrade, Serbia.
Currently working in Microsoft as Program Manager on SQL Server product.
Member of JQuery community - created few popular plugins (four popular JQuery DataTables add-ins and loadJSON template engine).
Interests: Web and databases, Software engineering process(estimation and standardization), mobile and business intelligence platforms.