<script id=
"popup_editor"
type=
"text/x-kendo-template"
>
<div class=
"k-edit-label"
>
<label
for
=
"idState"
>State</label>
</div>
<input id=
"dropDownListState"
name=
"IdState"
>
</script>
$(
"#dropDownListState"
+ id).kendoDropDownList({
dataSource: {
transport:
{
read:
{
type:
"GET"
,
url:
function
() {
return
RecebimentoRoutes.LoadState()},
contentType:
'application/json; charset=utf-8'
}
}
},
dataTextField:
"Text"
,
dataValueField:
"Value"
,
change:
function
() {
value =
this
.value();
CityDataSource.filter({
field:
"Value"
,
operator:
"eq"
,
value: parseInt(value)
});
listCity.enable();
}
}).data(
"kendoDropDownList"
);
Hello,
Grid not displayed any record.
I want grid with autogeneratecolumn = true.
any help would be appreciated......
public
ActionResult getData([DataSourceRequest]DataSourceRequest request)
{
List<Class1> c1s =
new
List<Class1>();
for
(
int
i = 0; i < 5; i++)
{
Class1 c1 =
new
Class1();
c1.ID = i;
c1.Name =
"Name"
+ i;
c1s.Add(c1);
}
return
Json(c1s.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}
[Serializable]
public
class
Class1
{
public
int
ID {
get
;
set
; }
public
string
Name {
get
;
set
; }
}
<
div
id
=
"mygrid"
>
</
div
>
<
script
type
=
"text/javascript"
>
$(document).ready(function () {
$("#mygrid").kendoGrid({
dataSource: {
type: "odata",
serverPaging: true,
serverSorting: true,
pageSize: 100,
transport: {
read: "/Home/getData"
}
},
height: 280,
scrollable: {
virtual: true
},
sortable: true
});
});
</
script
>
Note : There is not any JS error.
If i tried with below read method then its works.
read: "http://demos.kendoui.com/service/Northwind.svc/Orders"
Thanks,
Jason
Hi,
i fill a grid step by step with many data from a database.
on load the grid is empty. an javascript fills the grid with a result of an ajax-request.
while he is loading the items every "tick" of inserting new items to the datasource, the grid lost the user-written text in the filters, so the user have to rewrite it.
you also lost the selecection of an row.
it looks like the grid will be rebuild in the DOM every time i add an item.
is there any mechanic to prevent this?
thats my grid:
@(Html.Kendo().Grid<
Object
>().Name("KomplettabbzuegeGrid")
.ToolBar(toolBar => toolBar.Custom()
.Text("<
i
class
=
'icon-download'
></
i
>Exportieren")
.HtmlAttributes(new { id = "export" })
.Url(Url.Action("Export", "Vorbereitung", new { page = 1, pageSize = "~", filter = "~", sort = "~", initGruppenId = ViewBag.CurrKompfGrp }))
)
.Columns(columns =>
{
columns.Bound("Vfnr").Title("VFNR").Filterable(true);
columns.Bound("Betriebsname").Title("Betrieb").Filterable(true);
columns.Bound("Ort").Title("Ort").Filterable(true);
columns.Bound("HochgeladenAmDatum").Format("{0:dd.MM.yyyy hh:mm}").Title("Hochgeladen am").Filterable(false);
columns.Bound("Status").Title("Status")
.ClientTemplate("#= (Status == 2 ? 'offen': " +
"(Status == 3 ? 'akzeptiert':" +
"(Status == 4 ? 'abgelehnt': 'unbekannt'" +
"))) #")
.Filterable(false);
columns.Bound("Terminstellung").Title("Terminstellung")
.ClientTemplate("#= (Terminstellung == 'A' ? 'Welle 1': " +
"(Terminstellung == 'B' ? 'Welle 2':" +
"(Terminstellung == 'C' ? 'Welle 3': 'unbekannt'" +
"))) #")
.Filterable(false);
})
.Sortable(x => x.Enabled(true))
.Pageable(x => x.Enabled(true))
.Selectable(selectable => selectable.Mode(GridSelectionMode.Multiple))
.Events(c => c.DataBound("function (e) {CollapseAllRows('#KomplettabbzuegeGrid');}").DataBound("onDataBound"))
.Filterable()
.Resizable(c => c.Columns(true))
.Groupable()
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
.Sort(sort => sort.Add("HochgeladenAmDatum").Descending())
))
and thas the javascript wich adds the lines:
function
loadGridData(gridDataSource, url, data)
{
if
(
typeof
data[
'skip'
] ===
"undefined"
||
typeof
data[
'take'
] ===
"undefined"
)
return
;
if
(grpId != data[
"initGruppenId"
]) {
return
;
}
$.ajax(
{
type:
'POST'
,
url: url,
dataType:
'json'
,
data: data,
success:
function
(result)
{
if
(grpId != data[
"initGruppenId"
])
return
;
if
(result.Data ==
null
)
return
;
for
(
var
i = 0; i < result.Data.length; i++)
{
gridDataSource.add(result.Data[i]);
}
data[
'skip'
] = data[
'skip'
] + data[
'take'
];
loadGridData(gridDataSource, url, data);
},
error:
function
(result)
{
return
;
}
});
}
<script>
$(document).ready(
function
() {
var
crudServiceBaseUrl =
"http://demos.kendoui.com/service"
,
dataSource =
new
kendo.data.DataSource({
transport: {
read: {
dataType:
"json"
},
destroy: {
dataType:
"jsonp"
,
contentType:
"application/json; charset=utf-8"
},
parameterMap:
function
(options, operation) {
if
(operation !==
"read"
&& options.models) {
return
{models: kendo.stringify(options.models)};
}
}
},
batch:
true
,
pageSize: 30,
schema: {
data:
"myList"
,
model: {
id:
"uuid"
,
fields: {
uuid: { editable:
false
, nullable:
true
},
lang: { type:
"string"
},
text: { type:
"string"
}
}
}
}
});
$(
"#grid"
).kendoGrid({
dataSource: dataSource,
pageable:
true
,
height: 400,
toolbar: [
"create"
],
columns: [
{ field:
"lang"
, title:
"Language"
},
{ field:
"text"
, title:
"Text"
, width:
"150px"
},
{ command: [
"edit"
,
"destroy"
], title:
" "
, width:
"210px"
}],
editable:
"popup"
});
});
</script>
callback | jQuery17201980517354870166_1353667373995 |
models | [{"lang":"de","text":"ProjectRoot-System","uuid":"c0437761-1c29-11e2-892e-0800200c9a66"},{"lang":"de","text" :"Stephan","uuid":"46baf7b1-2345-11e2-81c1-0800200c9a66"}] |
org.apache.struts2.json.JSONReader.buildInvalidInputException(JSONReader.java:155)
I did a debugging on the JSONInterceptor and found out that the json variable when trying to do the deserialize
Object obj = JSONUtil.deserialize(request.getReader());
the json variable is an empty string. Thus the above error.
Second Scenario
Instead of calling a function to delete, i changed that to call an action. When doing this, the action
is called and my String models variable is set with the following values [{"lang":"de","text":"ProjectRoot-System","uuid":"c0437761-1c29-11e2-892e-0800200c9a66"}].
This seems sort of correct. Unfortunately with this case, the whole process does not go through the
JSONInterceptor, so no deserialization is happening.
So what is my goal:
To be able when pressing on delete to call the delete function and set the object with the values that are
sent from kendo in order to continue with my own business logic process. What could be wrong
in my first scenario ?
Please let me know if you need further information.
Regards
Stephan