Continuation from this post here
So i found out a way to keep the data without using cookies, where i sent it to the controller using Ajax.
Then in my controller, i defined the following, so that the prefs will persist within the controller even if the page changed
class MyController {
static prefs = [] as List
def index() {}
def list([prefs:prefs]) {}
def save() {}
def update() {}
def testPrefs() {
def value = []
def model = []
def colNames = []
def sortorder
def sortname
def grid
def rows
Map map = [:]
map.value = params.'value[]'?.toString()
map.model = params.'model[]'?.toString()
map.column = params.'colNames[]'?.toString()
map.sortorder = params.'sord'
map.sortname = params.'sorn'
map.grid = params.'grid'
map.rows = params.'rows'
prefs.add(map)
}
}
Where in the list page, it will retrieve the value of prefs
var prefs = "${prefs}";
But problem is, when i tried to retrieve the prefs on javascript, it gives me the following return
[{value=[a, b, c], model=[aa, bb, cc], column=[aaa, bbb, ccc, ddd], sortorder=desc, sortname=id, grid=#gridId, rows=50}]
instead of a JSON data.
Is it possible to read such data on Javascript? I tried getting prefs.value or prefs.sortorder but it shows undefined instead.
Thanks