I have managed to send the bookmark from the view to the action with custom DataManager and adding a parameter to the query. Now the problem is how to retrieve the bookmark from the action response?
function begin(args) {
if (!this.initialRender) {
var first = args.model.currentViewData[0];
var last = args.model.currentViewData[11];
args.model.query.addParams("first", JSON.stringify(first));
args.model.query.addParams("last", JSON.stringify(last));
}
} |
|
Hello Vignesh,
Thanks for your response. Could you be more specific. I couldn't understand when should I call this function.
Best regards,
Botyo
@(Html.EJ().Grid<object>("FlatGrid")
.Datasource(ds => ds.URL(@Url.Action("UrlDataSource")).Adaptor(AdaptorType.UrlAdaptor))
.AllowPaging() /*Paging Enabled*/
.AllowScrolling()
.ClientSideEvents(p => p.ActionBegin("begin"))
.Columns(col =>
{
-------------------
}))
<script type="text/javascript">
function begin(args) {
if (!this.initialRender) {
var first = args.model.currentViewData[0];
var last = args.model.currentViewData[11];
args.model.query.addParams("first", JSON.stringify(first));
args.model.query.addParams("last", JSON.stringify(last));
}
}
</script> |
public ActionResult Data(CustomDataManger dm)
{
---------------------
return Json(new { result = Data, count = count }, JsonRequestBehavior.AllowGet);
}
public class CustomDataManger : DataManager
{
public EditableOrder first { get; set; }
public EditableOrder last { get; set; }
}
-----------------------------------
@(Html.EJ().Grid<object>("HierarchyGrid")
.Datasource(ds => ds.URL("/Grid/Data").UpdateURL("/Grid/Update").InsertURL("/Grid/Insert").RemoveURL("/Grid/Delete").Adaptor(AdaptorType.UrlAdaptor))
-------------------------
.ClientSideEvents(eve => eve.Load("load"))
)
<script>
function load(args) {
this.model.dataSource.adaptor = new customAdaptor();
}
var customAdaptor = new ej.UrlAdaptor().extend({
processQuery: function (dm, query, hierarchyFilters) {
var obj = ej.UrlAdaptor.prototype.processQuery(dm, query, hierarchyFilters);
var data = ej.parseJSON(obj.data);
var grid = $("#HierarchyGrid").ejGrid("instance");
if (grid.model.pageSettings.currentPage > 1) {
data.first = grid.model.currentViewData[0];
data.last = grid.model.currentViewData[grid.model.pageSettings.pageSize - 1];
}
return {
data: JSON.stringify(data),
url: obj.url,
ejPvtData: obj.ejPvtData,
type: "POST",
contentType: "application/json; charset=utf-8"
}
}
});
</script> |
public ActionResult Data(CustomDataManger dm)
{
-------
return Json(new { result = Data, count = count, Bookmark = "New Bookmark" }, JsonRequestBehavior.AllowGet);
}
var customAdaptor = new ej.UrlAdaptor().extend({
processQuery: function (dm, query, hierarchyFilters) {
-----------
},
processResponse: function (data, ds, query, xhr, request, changes) {
var bookMark = data.bookMark;
return data;
},
}); |