hello,
i want to use kendo to send data to a REST API. I get a 415 error. But i do not know what i have made wrong.
My test html looks like this:
<button id="button" type="button">Submit</button>
<script>
$("#button").kendoButton({
click: function (e) {
//alert(combobox.value);
//alert(e.event.target.tagName);
var dataSource = new kendo.data.DataSource({
transport: {
// make JSONP request to https://demos.telerik.com/kendo-ui/service/products/create
create: {
url: "https://localhost:7170/api/Kunden",
dataType: "json", // "jsonp" is required for cross-domain requests; use "json" for same-domain requests
type: "PUT"
},
parameterMap: function (data, type) {
if (type == "create") {
// send the created data items as the "models" service parameter encoded in JSON
return { models: kendo.stringify(data.models) };
}
}
},
schema: {
model: {
id: "kundenId", // the identifier of the model
fields: {
id: { editable: false, nullable: true },
}
}
}
});
// create a new data item
dataSource.add({ id: 4713 });
//dataSource.insert(0, { id: 4714 });
// save the created data item
dataSource.sync(); // server response is [{"ProductID":78,"ProductName":"New Product","UnitPrice":0,"UnitsInStock":0,"Discontinued":false}]
//dataSource.pushCreate([{ id: combobox.value }]);
}
});
</script>
My API controller looks like this. I want to use the method SetKunde.
namespace Api.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class KundenController : ControllerBase
{
// GET: api/Kunden
[HttpGet]
public async Task<ActionResult<IEnumerable<Kunde>>> GetKundeItems()
{
//return await _context.KundeItems.ToListAsync();
DataAccess dataAccess = new DataAccess();
return dataAccess.GetKunden();
}
// GET: api/Kunden/5
[HttpGet("{id}")]
public async Task<ActionResult<Kunde>> GetKunde(long id)
{
//var kunde = await _context.KundeItems.FindAsync(id);
DataAccess dataAccess = new DataAccess();
Kunde kunde = dataAccess.GetKunde(id);
if (kunde == null)
{
return NotFound();
}
return kunde;
}
// PUT: api/Kunden/5
[HttpPut]
public async Task<ActionResult<Kunde>> SetKunde(KundeShort kdn)
{
return NotFound();
}
}
}
So I have data in this format
{
name: health
data:[[1,2],[2,2],[3,4]]
type:"area"
visible:true
},
{
name: health2
data:[[1,2],[2,2],[3,4]]
type:"line"
visible:true
}
I have attached a screenshot of what i want to achieve need guidance to do this I'm new to kendo .
i have controller using java as @RequestMapping("/charts") and it return in Json format but my question this data is not reflected in my Grid why.
$("#grid").kendoGrid({
dataSource: {
transport: {
read: {
url: function(options)
{ return "${pageContext.request.contextPath}/charts";
},
dataType: "json",
type: "GET"
}
},
schema:{
model: {
fields: {
id: { type: "number" },
fullName : { type: "string" },
address: { type: "string" },
email : { type: "string" },
password: { type: "string" },
designation: { type: "string" },
salary: { type: "number" }
}
}
},
aggregate: [ { field: "fullName", aggregate: "count" },
{ field: "salary", aggregate: "sum" }
]
,pageSize: 8 },
sortable: true,
scrollable: false,
pageSize: 5,
pageSizes: true,
hieght:20,
pageable: {
pageSizes: [4, 6,10,"all"],
buttonCount: 5
},
columns: [
{ field: "id", title: "ID", width: 180 },
{ field: "fullName", title: "Name",width:300,
template: "<div style=color:red>#=fullName#</div>" ,footerTemplate: "Total Count: #=count#" },
{ field: "address", title: "Address",width:300 },
{ field: "email", title: "Email",width:200},
{ field: "password", title: "Password" ,width:200},
{ field: "designation", title: "Designation" ,width:300},
{ field: "salary", title: "Salary" ,width:200,footerTemplate: "Total Sum: #=sum#"},
{ width:200,
template: "<a class='k-button' href='/Home/Index'>Redirect</a>" }
]
});
In Export as Excel limited data is only Shown, If we add more data in the Kendo Table Grid, Additionally, When we click on Export as Excel, only the same set of data is shown, without any new data being added to the Excel Sheet.
See here Data is upto 45 in Kendo Table but when we export as Excel then only upto 32 data is loading, no new data is being loaded on Excel Sheet.
Download kendo ui trial and in exmaple i just try following code
place these two file at "Kendo 2023\examples\dropdownlist" and run you will find "Blocked a frame with origin "null" from accessing a cross-origin frame."
parent.html is as below
<html lang="en">
<head>
<title>Parent Frame</title>
<script>
___data = [
{ CityID: 1, CityName: "Lisboa" },
{ CityID: 2, CityName: "Moscow" },
{ CityID: 3, CityName: "Napoli" },
{ CityID: 4, CityName: "Tokyo" },
{ CityID: 5, CityName: "Oslo" },
{ CityID: 6, CityName: "Pаris" },
{ CityID: 7, CityName: "Porto" },
{ CityID: 8, CityName: "Rome" },
{ CityID: 9, CityName: "Berlin" },
{ CityID: 10, CityName: "Nice" },
{ CityID: 11, CityName: "New York" },
{ CityID: 12, CityName: "Sao Paulo" },
{ CityID: 13, CityName: "Rio De Janeiro" },
{ CityID: 14, CityName: "Venice" },
{ CityID: 15, CityName: "Los Angeles" },
{ CityID: 16, CityName: "Madrid" },
{ CityID: 17, CityName: "Barcelona" },
{ CityID: 18, CityName: "Prague" },
{ CityID: 19, CityName: "Mexico City" },
{ CityID: 20, CityName: "Buenos Aires" }
]
</script>
</head>
<body>
<iframe src="./child.html" style="height: 100vh;width: 100vw;border: 0;"></iframe>
</body>
</html>
and child.html is as below
<!DOCTYPE html>
¿Alguien ha trabajado con esto? Tengo configurado el web service y me esta retornando el json que debe leerme y mostrarme en el grid, pero no consigo realizar que se visualicen los datos
<body>
<div id="grid"></div>
<script>
$(document).ready(function () {
const dataSource = new kendo.data.DataSource({
dataSource: {
type: "odata",
transport: {
read: "http://localhost:53072/Service.svc/ObtenerDatos"
},
pageSize: 20
},
schema: {
model: {
fields: {
Id: { type: "number" },
Nombre: { type: "string" },
Precio: { type: "number" }
}
}
},
pageSize: 10
});
$("#grid").kendoGrid({
dataSource: dataSource,
height: 400,
sortable: true,
pageable: true,
columns: [
{ field: "Id", title: "ID" },
{ field: "Nombre", title: "Nombre" },
{ field: "Precio", title: "Precio" }
],
});
});
</script>
</body>
Hi,
We're trying to use the inline edit functionality of the Grid using the code below. But receiving an error 400 when trying to post using the "create" function of the Kendo DataSource.
JS
const dataSourceMeetingTypes = new kendo.data.DataSource({
transport: {
read: endpoint + "/read",
create: {
url: endpoint + "/create",
type: "POST",
data: function (e) {
return kendo.stringify(e);
},
contentType: "application/json; charset=utf-8"
}
},
error: function (e) {
//console.log(e);
},
schema: {
model: {
fields: {
meetingType: { type: "string" },
meetingValue: { type: "string" }
}
}
},
pageSize: 5
});
Controller
[ApiController]
[Route("create")]
public class CreateController : ControllerBase
{
[HttpPost]
public ActionResult Create([FromBody] MeetingTypes meetingTypes)
{
}
}
public class MeetingTypes
{
public string MeetingType { get; set; }
public string MeetingValue { get; set; }
}
But the below code works outside the Grid. The data from the javascript above - kendo.stringify(e) matches the data below. Using Postman with the below data also works with no issue.
$.ajax({
type: "POST",
url: endpoint + "/create",
data: "{\"meetingType\":\"test123\",\"meetingValue\":\"test123\"}",
contentType: "application/json; charset=utf-8"
}).done(function (response) {
});
Any help is much appreciated.
Thanks
I am looking for a help where I need to recreate the options for column filter values when the data on left hand side filter changes?
I have a drop down list country on left hand side and when ever user select the country the column(region), filter (custom filter, based on column on the grid) all the checkboxes for the custom filter should reflect the region as per the country selected.
Hi guys,
I searched all the documents but there was nothing about binding more than 1 view. I have an error about length.
Here is the error:
Uncaught TypeError: Cannot read properties of null (reading 'length')
at o (kendo.ui.core.js:11901:65)
at r (kendo.ui.core.js:11933:51)
at r (kendo.ui.core.js:11983:67)
at r (kendo.ui.core.js:11983:67)
at r (kendo.ui.core.js:11983:67)
at r (kendo.ui.core.js:11983:67)
at Object.s [as bind] (kendo.ui.core.js:11998:9)
at TakvimDonemTanimlariService.initialize (TakvimDonemTanimlariService.js?v=DWpWtbx8AYW9jERt4Zt9itqDau9V9clzgEHhorRx-l8:400:15)
at HTMLDocument.<anonymous> (TakvimDonemTanimlariService.js?v=DWpWtbx8AYW9jERt4Zt9itqDau9V9clzgEHhorRx-l8:410:33)
at mightThrow (jquery.js:3557:29)
Here is what I am binding:
kendo.bind($(".service-body"), takvimDonemTanimlariService);
kendo.bind($(".form-wrapper"), takvimDonemTanimlariService);
How can I solve this problem?
Hello,
I ran into an relatively simple issue and I just can not find out how to do it.
I have a Donut Chart which I want to fill with remote data.
function createCharts() {
var showLabels = $(document).width() > 677;
$("#overview-chart").kendoChart({
theme: "sass",
dataSource: {
data: [
{ value: countOrderFinished, type: "New Orders" },
{ value: 30, type: "Orders in Process" },
{ value: 180, type: "Finished Orders" },
]
},
series: [{
type: "donut",
field: "value",
categoryField: "type",
startAngle: 70,
holeSize: 55
}],
legend: {
position: "bottom"
}
});
kendo.resize($(".k-grid"));
}
$(document).ready(createCharts);
$(document).bind("kendo:skinChange", createCharts);
$(window).on("resize", function () {
kendo.resize($(".k-chart"));
});
How would I manage to fill my Variable countOrderFinished with remote data? I tried this way, but it did not work:
var countOrderFinished = new kendo.data.DataSource({ type: "json", read: { url: "Services/OrderServices.asmx/GetCountOrderFinished", contentType: 'application/json; charset=utf-8', type: "POST" }, });
I think it is a simple solution but I just cant get it.
Thank you for your Help!