or
var
MyDatasource =
new
kendo.data.DataSource({
type:
'odata'
/* for odata style IQueryable web api */
serverPaging:
true
,
serverSorting:
true
,
pageSize: 15,
transport: {
read: {
dataType:
"json"
,
url:
"mywebapi/mydata"
})
The DataSource is used by a Kendo grid with scrollable: { virtual: true }.
A user has the ability to search for data where the searchparam is set on my viewmodel.
within my viewmodel i simply call "MyDatasource.read({ searchvalue: userparam })" to get the data from my web-api which works perfectly.
However, in combination with paging the parameter is lost when reading the next page.
Is there any way to preserve that param so it gets send with the next pages as well ?
Thanks in advance.
$("#level3-multiselect").kendoMultiSelect({
autoBind: false,
dataTextField: "name",
dataValueField: "id",
dataSource: {
serverFiltering: true,
transport: {
dataType: "jsonp",
read: baseurl: 'http://myurl'
parameterMap: function(options, operation) {
var _name = "";
if ('filter' in options && options.filter.filters.length > 0) {
_name = options.filter.filters[0].value;
}
return {
level1ids: getLevel1Ids().join(),
level2ids: getLevel2Ids().join(),
name: _name
}
}
},
schema: {
data: "items"
}
}
});
Sector1
Category1
Category2
Category2-1
category2-2
Sector2
Category1
Category2
Category2-1
category2-2
@(Html.Kendo().TreeView()
.Name("categoryList")
.DataTextField("Name")
.DragAndDrop(true)
.DataSource(ds =>
{
// ds.Read("ajaxCateegoryList", "category");
ds.Read(read => read.Action("ajaxCateegoryList", "category"));
})
.Events(evt =>
{
evt.Expand("expandHandler");
evt.Select("selectedHandler");
})
)
public
JsonResult ajaxCateegoryList(
string
id)
{
if
(
string
.IsNullOrEmpty(id))
id = Request.QueryString[
"id"
];
var cats =
new
List<Category>();
if
(!
string
.IsNullOrEmpty(id))
cats = _categoryService.GetAllCategoriesByParentCategoryId(Convert.ToInt64(id)).ToList();
else
cats = _categoryService.getAllParentCategories();
var model = cats.Select(x =>
{
return
new
{
id = x.Id,
Name = x.Name,
hasChildren = _categoryService.GetAllCategoriesByParentCategoryId(x.Id).Count > 0
};
});
return
Json(model, JsonRequestBehavior.AllowGet);
}