Merge pull request #6903 from SammyG4Free/master

Type Definitions for DataTables Buttons extension.
This commit is contained in:
Masahiro Wakame
2016-02-03 00:01:47 +09:00
2 changed files with 146 additions and 0 deletions
@@ -0,0 +1,33 @@
/// <reference path="../jquery/jquery.d.ts" />
/// <reference path="../jquery.dataTables/jquery.dataTables.d.ts" />
/// <reference path="datatables-buttons.d.ts" />
$(document).ready(function () {
var config: DataTables.Settings =
{
// Buttons extension options
buttons: [
{
extend: 'excel',
text: 'Excel',
className: 'class',
exportOptions: {
columns: ':visible'
}
},
{
action: function (e, dt, node, config) { },
available: function (dt, config) { return true; },
destroy: function (dt, node, config) { },
enabled: true,
init: function (dt, node, config) { },
key: 'a',
name: 'name',
namespace: 'namespace',
titleAttr: 'title',
}
],
}
});
+113
View File
@@ -0,0 +1,113 @@
// Type definitions for JQuery DataTables Buttons extension 1.1.0
// Project: http://datatables.net/extensions/buttons/
// Definitions by: Sam Germano <https://github.com/SammyG4Free>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../jquery/jquery.d.ts" />
/// <reference path="../jquery.dataTables/jquery.dataTables.d.ts"/>
declare module DataTables {
export interface Settings {
/**
* Buttons extension options
*/
buttons?: boolean | string[] | ButtonSettings[];
}
//#region "button-settings"
/**
* Buttons extension options
*/
export interface ButtonSettings {
/**
* Action to take when the button is activated
*/
action?: FunctionButtonAction;
/**
* Ensure that any requirements have been satisfied before initialising a button
*/
available?: FunctionButtonAvailable;
/**
* Set the class name for the button
*/
className?: string;
/**
* Function that is called when the button is destroyed
*/
destroy?: FunctionButtonInit;
/**
* Set a button's initial enabled state
*/
enabled?: boolean;
/**
* Define which button type the button should be based on
*/
extend?: string;
/**
* Initialisation function that can be used to add events specific to this button
*/
init?: FunctionButtonInit;
/**
* Define an activation key for a button
*/
key?: string | ButtonKey;
/**
* Set a name for each selection
*/
name?: string;
/**
* Unique namespace for every button
*/
namespace?: string;
/**
* The text to show in the button
*/
text?: string | ButtonText;
/**
* Button 'title' attribute text
*/
titleAttr?: string;
exportOptions?: ButtonExportOptions;
autoPrint?: boolean;
}
export interface FunctionButtonAvailable {
(dt: DataTables.DataTable, config: any): boolean
}
export interface ButtonExportOptions {
columns?: string;
}
export interface ButtonKey {
key?: string;
shiftKey?: boolean;
altKey?: boolean;
ctrlKey?: boolean;
metaKey?: boolean;
}
export interface ButtonText {
(dt: DataTables.DataTable, node: JQuery, config: any): string
}
export interface FunctionButtonInit {
(dt: DataTables.DataTable, node: JQuery, config: any): void
}
// api object?
export interface FunctionButtonAction {
(e: any, dt: DataTables.DataTable, node: JQuery, config: any): void
}
//#endregion "button-settings
}