addon/netnet.jsline 111
Add-on for binding to remote data
PARAMETERS
Name Type Description options
object
PROPERTIES
Name Type Description 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
Name Type Description 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 trueEXAMPLES
<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
readData(page, data, resetData)net.jsline 378
Requests 'readData' to the server. The last requested data will be extended with new data.
PARAMETERS
Name Type Description 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.
request(requestType, options)net.jsline 501
Send request to server to sync data
PARAMETERS
Name Type Description requestType
String
'createData|updateData|deleteData|modifyData'
options
object
Options
PROPERTIES
Name Type Description 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
