DataTables is a jQuery table plug-in.
Explanation with examples
1. Requirements: As shown in the figure below, add, edit, and delete the contents of datatables.
2. Analysis: Add function---click the add button to pop up a dialog box to add new content.
Editing function---Click datatables to select a row. The row changes color, which means it has been selected. Click the edit button to pop up the dialog. The content in this dialog is the content of the row we selected. If no row is selected and the edit button is clicked, the dialog will not pop up. When a row in datatables is double-clicked, a dialog will also pop up, and the double-clicked row changes color. The content in the dialog is the content of the row we double-clicked.
Deletion function---click datatables to select a row, click the delete button, and a warning box will pop up, prompting you whether to delete the selected content. When nothing is selected, clicking the delete button will not pop up a warning box, and the content will not be deleted.
3. Coding:
Attributes//Name
Name | Value | DisplayOrder |
---|
//声明dialog,异步更新 @using (Ajax.BeginForm("Update", "Product", new AjaxOptions { UpdateTargetId = "d_Attributes", OnSuccess = "dialogClose", HttpMethod = "Post", })) {
Name | * |
Value | * |
DisplayOrder | * |
Description of the above code: This code is mainly divided into two parts. The first part is The declaration of jquery datatables,
Description of the above code: This code is the declaration of dialog, and the declaration of datatables is operated by add, edit, and delete.
4. Paging implementation
Introducing CSS files and JS files
-------------------------------------------------------------------------- -----------最简单的方式: $(document).ready(function() { $("#example").dataTable(); }); ----------也可以自己定义各属性:
For dataTables, tables It must be explained through thead and tbody, as shown below,
Rendering engine | Browser | Platform(s) | Engine version | CSS grade |
---|---|---|---|---|
Trident | Internet Explorer 4.0 | Win 95+ | 4 | X |