Hi, i've been trying to get user grid preference saving following this link:
http://jsbin.com/anisip/31/edit
It's been very helpful so far with saving the data to my database.
However, i'm trying to load the saved data now but i cant seem to get it working.
In my database, i've saved the "state" of the object which looks similar to this:
"{"group":[{"field":"Supplier","dir":"asc","aggregates":[]}]}"
When i load my page i try to load the user grid preference from the database (due to filtering needed as soon as the window loads, i have this method in the window.load() function).
var grid = $("#Grid").data("kendoGrid");
// Load grid preferences.
$.post("Home/LoadGridPreference", { forScreen: "" }, function (data) {
var state = JSON.parse(data);
if (state) {
grid.dataSource.query(state);
} else {
grid.dataSource.read();
}
});
I have checked that the data i get in "state" is indeed the same as before i stringified the grid information.
However when it gets to the stage grid.dataSource.query(state), nothing seems to happen , i cant see any ordering that i have saved in the database.
Also, to test out whether its the "state" value not being set correctly, i have tried to manually override this by using the exact values from when the "state" value was set. i.e. i have tried this grid.dataSource.query("{"group":[{"field":"Supplier","dir":"asc","aggregates":[]}]}")
Yet this does not work either.
I can see that it's trying to do something as this seems to make the row counter (located on the bottom right of the screen) to say NaN - NaN of 3 items.
The example on JSBin works perfectly using cookies, but why isn't this working when i implement this on my project and save the grid preferences into the database?
Thanks
http://jsbin.com/anisip/31/edit
It's been very helpful so far with saving the data to my database.
However, i'm trying to load the saved data now but i cant seem to get it working.
In my database, i've saved the "state" of the object which looks similar to this:
"{"group":[{"field":"Supplier","dir":"asc","aggregates":[]}]}"
When i load my page i try to load the user grid preference from the database (due to filtering needed as soon as the window loads, i have this method in the window.load() function).
var grid = $("#Grid").data("kendoGrid");
// Load grid preferences.
$.post("Home/LoadGridPreference", { forScreen: "" }, function (data) {
var state = JSON.parse(data);
if (state) {
grid.dataSource.query(state);
} else {
grid.dataSource.read();
}
});
I have checked that the data i get in "state" is indeed the same as before i stringified the grid information.
However when it gets to the stage grid.dataSource.query(state), nothing seems to happen , i cant see any ordering that i have saved in the database.
Also, to test out whether its the "state" value not being set correctly, i have tried to manually override this by using the exact values from when the "state" value was set. i.e. i have tried this grid.dataSource.query("{"group":[{"field":"Supplier","dir":"asc","aggregates":[]}]}")
Yet this does not work either.
I can see that it's trying to do something as this seems to make the row counter (located on the bottom right of the screen) to say NaN - NaN of 3 items.
The example on JSBin works perfectly using cookies, but why isn't this working when i implement this on my project and save the grid preferences into the database?
Thanks