No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
Saúl Ortega 70cce2b4c7
Update README.md
hace 6 años
.gitignore Initial commit hace 6 años
LICENSE Initial commit hace 6 años
README.md Update README.md hace 6 años
filter.go Update and rename datatables.go to filter.go hace 6 años
generic.go Create generic.go hace 6 años
response.go Create response.go hace 6 años

README.md

datatables

Simple parser for DataTables server-side processing.

Install

go get -u github.com/saulortega/datatables

Usage

import "github.com/saulortega/datatables"

//Parse receive *http.Request and returns a Filter struct
filter, err = datatables.Parse(r)
if err != nil {
	//Handle error
}

//Get data from DB

response := filter.PrepareResponse()
response.RecordsTotal = 629635
response.RecordsFiltered = 50
response.Data = rows

//WriteResponse receive http.ResponseWriter. It send the response even if there are any error.
//Use WriteResponseOnSuccess(w) if you do not want to send the response when there is an error.
err := response.WriteResponse(w)
if err != nil {
	//Handle error
}

Structs

type Filter struct {
	Draw        int
	Start       int
	Length      int
	Order       []Order
	Columns     []Column
	SearchValue string
	SearchRegex bool
}

type Column struct {
	Data        string
	Name        string
	Index       int
	Orderable   bool
	Searchable  bool
	SearchValue string
	SearchRegex bool
}

type Order struct {
	Column Column
	Dir    string
}