Basic initialisation

Editor is a Create, Read, Update and Delete (CRUD) extension forDataTables that provides the ability to easily add, edit and delete rows on a database that is displayed by a DataTable. Editor provides a clean and responsive interface for end user manipulation of data, an expressive API for complete control and a well defined server communications protocol for data submission.

This simple example shows a table with seven fields, each of which can be edited as plain text. In other examples we will explore how to add date pickers, select elements and other controls to make form input intuitive for the system user, among many other aspects of the Editor API.

<table id="example" class="display" cellspacing="0" width="100%">

        <thead>
            <tr>
                <th>Name</th>
                <th>Position</th>
                <th>Office</th>
                <th>Extn.</th>
                <th>Start date</th>
                <th>Salary</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th>Name</th>
                <th>Position</th>
                <th>Office</th>
                <th>Extn.</th>
                <th>Start date</th>
                <th>Salary</th>
            </tr>
        </tfoot>
    </table>

var editor; // use a global for the submit and return data rendering in the examples

 
$(document).ready(function() {
    editor = new $.fn.dataTable.Editor( {
        ajax: "../php/staff.php",
        table: "#example",
        fields: [ {
                label: "First name:",
                name: "first_name"
            }, {
                label: "Last name:",
                name: "last_name"
            }, {
                label: "Position:",
                name: "position"
            }, {
                label: "Office:",
                name: "office"
            }, {
                label: "Extension:",
                name: "extn"
            }, {
                label: "Start date:",
                name: "start_date",
                type: "datetime"
            }, {
                label: "Salary:",
                name: "salary"
            }
        ]
    } );
 
    $('#example').DataTable( {
        dom: "Bfrtip",
        ajax: "../php/staff.php",
        columns: [
            { data: null, render: function ( data, type, row ) {
                // Combine the first and last names into a single table field
                return data.first_name+' '+data.last_name;
            } },
            { data: "position" },
            { data: "office" },
            { data: "extn" },
            { data: "start_date" },
            { data: "salary", render: $.fn.dataTable.render.number( ',''.', 0, '$' ) }
        ],
        select: true,
        buttons: [
            { extend: "create", editor: editor },
            { extend: "edit",   editor: editor },
            { extend: "remove", editor: editor }
        ]
    } );
} );

how to use datatables editor的更多相关文章

  1. datatables editor fields type

    其实editor fields type 默认支持的输入类型就是w3c输入框类型. text   number   password   textarea   select   checkbox   ...

  2. js page click

     DataTables  Editor Your account: Login / Register Examples Manual Reference Options API Events Butt ...

  3. datatables中的Options总结(3)

    datatables中的Options总结(3) 十.ColReorder colReorder.fixedColumnsLeft 不允许x列重新排序(从左数) colReorder.fixedCol ...

  4. datatables中的Options总结(2)

    datatables中的Options总结(2) 五.datatable,列 columnDefs.targets 分配一个或多个列的列定义. columnDefs 设置列定义初始化属性. colum ...

  5. Datatables JQuery插件

    Datatables是一款jquery表格插件.它是一个高度灵活的工具,可以将任何HTML表格添加高级的交互功能. 分页,即时搜索和排序 几乎支持任何数据源:DOM, javascript, Ajax ...

  6. Datatables 在asp.net mvc中的使用

    前言 最近使用ABP(ASP.NET Boilerplate)做新项目,以前都是自己扩展一个HtmlHelper来完成同步/异步分页,但是有个地方一直不满意,排序太费劲. 以前接触过一点点的Datat ...

  7. JQuery DataTables Editor---页面内容修改&&数据库信息修改 (2)

    接上篇博文,详细说一下js代码以及JQuery DataTables Editor---页面内容修改&&数据库信息修改遇到的问题和解决办法. 1.关于dialog 初始化: $(&qu ...

  8. JQuery DataTables Editor---只修改页面内容

    近来在工作中需要对JQuery DataTables进行增,删,改的操作,在网上找了一些资料,感觉比较的好的就是(http://editor.datatables.net/)文章中所展示的操作方法(如 ...

  9. JQuery DataTables Editor---页面内容修改&&数据库信息修改 (1)

    我们使用jquery datatables 不光是为了对数据的展示,同时需要对数据惊行简单的操作,这个操作分为两个部分:1.页面内容的修改:2.对应的数据库信息的修改. 前一篇博文介绍了页面级的操作, ...

随机推荐

  1. Python-接口自动化(十一)

    配置文件的作用(十一) (十二)配置文件 1.python当中有一个模块可以读取配置文件里面的信息:configparser,对这个模块进行导入之后就可以使用了,import configparser ...

  2. JavaIO基础学习笔记

    JavaIO JavaIO即Java的输入输出系统.比如我们的程序要读取一个文本文件.一张图片或者要获取控制台输入的内容,就要用到输入流:又或者程序要将生成的一段字符窜以文件的形式保存到系统中就要用到 ...

  3. 如何取SQL结果集的第一条记录

    在SQL Server数据库中,使用top关键字: SELECT TOP number|percent column_name(s) FROM table_name 在MySQL数据库中,使用LIMI ...

  4. 在mac下安装matplotlib,xlrd

    brew install freetype brew install libpng sudo easy_install pip#图形显示模块 sudo pip install matplotlib 输 ...

  5. git clone, push, pull, fetch 的用法

    Git是目前最流行的版本管理系统,学会Git几乎成了开发者的必备技能. Git有很多优势,其中之一就是远程操作非常简便.本文详细介绍5个Git命令,它们的概念和用法,理解了这些内容,你就会完全掌握Gi ...

  6. CSU 1290 DP解决数学期望问题

    题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1290 题目大意: 给定k个数,每次可以生成0-N-1中的任何一个数,k个数中出现不同的整 ...

  7. codeforces 315B

    #include<stdio.h> int main() { int n,k,i,flag=0; while(scanf("%d%d",&n,&k)!= ...

  8. 【bzoj1090】 [SCOI2003]字符串折叠

    [bzoj1090] [SCOI2003]字符串折叠 2014年3月9日3,1140 Description 折叠的定义如下: 1. 一个字符串可以看成它自身的折叠.记作S  S 2. X(S)是X ...

  9. Linux(2):基础命令

    linux 的规则: 1. linux 命令行组成结构:如下 [root@neo ~]# [用户名@主机名 当前工作路径]# ~ 用户的家目录 2. linux系统命令操作语法的格式(命令的样子): ...

  10. android GET 请求在5.0版本的取不到数据,报IO异常兼容问题解决

    使用lib类库xUtils-2.6.10.jar作为数据请求的框架,在android的5.0版会有兼容问题,取不到GET请求的数据. 但是POST没有问题,难取到数据. public static R ...