DataTables is a very good table, the use of go when the sorting problem is very troublesome, so wrote a function
Package Toolsimport ("Github.com/astaxie/beego/context" "StrConv")//datatables the sort func dt_order (acolumns []string, Input *context. Beegoinput) String {maps: = Make (map[string]string) if isortcol_0, _: = StrConv. Atoi (Input.query ("Isortcol_0")); Isortcol_0 >-1 {ranges, _: = StrConv. Atoi (Input.query ("Isortingcols")) for I: = 0; i < ranges; i++ {istring: = StrConv. Itoa (i) if isortcol: = Input.query ("Bsortable_" + input.query ("Isortcol_" +istring)); Isortcol = = "true" {sordir: = Input.query ("ssortdir_" + istring) Thissortcol, _: = StrConv. Atoi (Input.query ("Isortcol_" + istring)) if Sordir = = "ASC" {Maps[acolumns[thissortcol]] = "ASC"} else {maps[acolumns[ Thissortcol]] = "desc"}}}}var order Stringif len (maps) > 0 {for k, V: = Range Maps {if order = = "" {order = k + "" + V } else {order + = "," + K + "" + V}}}return Order}
How to use:
Order: = models. Dt_order ([]string{"id", "username", "password"}, this. Ctx.input)
Fmt. PRINTLN (Order)
Beego DataTables Sort function