logo

/github|v3.8.0

Module

addon/netnet.jsline 111

Add-on for binding to remote data

PARAMETERS
NameTypeDescription

options

object

PROPERTIES
NameTypeDescription

el

[ jquery ]

Form element (to be used for ajax request)

initialRequest

boolean = true

Whether to request 'readData' after initialized

readDataMethod

string = 'POST'

Http method to be used for 'readData' API ('POST' or 'GET')

api

[ object ]

URL map

PROPERTIES
NameTypeDescription

readData

[ string ]

URL for read-data

createData

[ string ]

URL for create

updateData

[ string ]

URL for update

modifyData

[ string ]

URL for modify (create/update/delete at once)

deleteData

[ string ]

URL for delete

downloadExcel

[ string ]

URL for download data of this page as an excel-file

downloadExcelAll

[ string ]

URL for download all data as an excel-file

perPage

number = 500

The number of items to be shown in a page

enableAjaxHistory

boolean = true

Whether to use the browser history for the ajax requests

withCredentials

boolean = false

Use withCredentials flag of XMLHttpRequest for ajax requests if true
allow cross-domain requests if true

EXAMPLES
<form id="data_form">
  <input type="text" name="query"/>
  </form>
  <script>
     var net;
     var grid = new tui.Grid({
         //...options...
     });

     // Activate 'Net' addon
     grid.use('Net', {
        el: $('#data_form'),
        initialRequest: true,
        readDataMethod: 'GET',
        perPage: 500,
        enableAjaxHistory: true,
        withCredentials: false,
        api: {
            'readData': './api/read',
            'createData': './api/create',
            'updateData': './api/update',
            'deleteData': './api/delete',
            'modifyData': './api/modify',
            'downloadExcel': './api/download/excel',
            'downloadExcelAll': './api/download/excelAll'
        }
     });

     // Bind event handlers
     grid.on('beforeRequest', function(data) {
         // For all requests
     }).on('response', function(data) {
         // For all response (regardless of success or failure)
     }).on('successResponse', function(data) {
         // Only if response.result is true
     }).on('failResponse', function(data) {
         // Only if response.result is false
     }).on('errorResponse', function(data) {
         // For error response
     });

     net = grid.getAddOn('Net');

     // Request create
     net.request('createData');

     // Request update
     net.request('updateData');

     // Request delete
     net.request('deleteData');

     // Request create/update/delete at once
     net.request('modifyData');
  </script>

Instance Methods

download(type)net.jsline 528

Change window.location to registered url for downloading data

PARAMETERS
NameTypeDescription

type

string

Download type. 'excel' or 'excelAll'.
Will be matched with API 'downloadExcel', 'downloadExcelAll'.

readData(page, data, resetData)net.jsline 378

Requests 'readData' to the server. The last requested data will be extended with new data.

PARAMETERS
NameTypeDescription

page

Number

Page number

data

Object

Data(parameters) to send to the server

resetData

Boolean

If set to true, last requested data will be ignored.

reloadData()net.jsline 368

Requests 'readData' with last requested data.

request(requestType, options)net.jsline 501

Send request to server to sync data

PARAMETERS
NameTypeDescription

requestType

String

'createData|updateData|deleteData|modifyData'

options

object

Options

PROPERTIES
NameTypeDescription

url

[ String ]

URL to send the request

hasDataParam

boolean = true

Whether the row-data to be included in the request param

checkedOnly

boolean = true

Whether the request param only contains checked rows

modifiedOnly

boolean = true

Whether the request param only contains modified rows

showConfirm

boolean = true

Whether to show confirm dialog before sending request

updateOriginal

boolean = false

Whether to update original data with current data

withCredentials

boolean = false

Use withCredentials flag of XMLHttpRequest for ajax requests if true

RETURNS:
{

boolean

} - Whether requests or not

setPerPage(perPage)net.jsline 549

Set number of rows per page and reload current page

PARAMETERS
NameTypeDescription

perPage

number

Number of rows per page

Resizable