Telerik Forums
Kendo UI for jQuery Forum
0 answers
34 views

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();
        }
   }
}
I hope someone can help.

Kind regards
Jens
Jens
Top achievements
Rank 1
Iron
 asked on 21 Dec 2023
0 answers
45 views

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 .

Hrushi
Top achievements
Rank 1
 asked on 28 Oct 2023
0 answers
37 views

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>"   }
                            
                        ]
                    });

kha
Top achievements
Rank 1
Iron
Iron
 asked on 22 Oct 2023
0 answers
42 views

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.

Mohit
Top achievements
Rank 1
 asked on 03 Oct 2023
0 answers
68 views

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>
<html lang="en">

<head>
  <title>Overview</title>
  <meta charset="utf-8">
  <link href="../content/shared/styles/examples-offline.css" rel="stylesheet">
  <link href="../../styles/default-ocean-blue.css" rel="stylesheet">
  <script src="../../js/jquery.min.js"></script>
  <script src="../../js/jszip.min.js"></script>
  <script src="../../js/kendo.all.min.js"></script>
  <script src="../content/shared/js/console.js"></script>


</head>

<body>
  <div class="k-d-flex k-flex-1 k-flex-col k-px-8 k-pt-7">
    <div class="kd-header k-d-flex k-gap-8 k-mb-6 k-justify-content-stretch">
      <div class="kd-header-core k-d-flex k-flex-col">
        <h2 class="k-h4 k-mt-0 k-mb-4 k-opacity-30">Time to order food</h2>
        <span class="k-d-inline-block">Find restaurants in your area</span>
        <input id="kd-place-chooser" />
        <div class="k-w-24 k-h-4 k-mt-5 k-skeleton k-opacity-40 k-rounded-md"></div>
        <div class="k-w-full k-h-8 k-mt-1.5 k-mb-auto k-skeleton k-opacity-30 k-rounded-md"></div>
        <div class="kd-actions k-d-flex k-mt-5 k-justify-content-end">
          <div class="k-w-20 k-h-8 k-skeleton k-opacity-40 k-rounded-md"></div>
          <div class="k-w-20 k-h-8 k-ml-4 k-skeleton k-opacity-50 k-rounded-md"></div>
        </div>
      </div>
      <div
        class="kd-image-wrapper !k-d-flex k-justify-content-center k-align-items-center k-skeleton k-opacity-10 k-border k-border-secondary k-border-solid k-rounded-md">
        <span class="k-icon k-i-image k-opacity-70"></span>
      </div>
    </div>
    <div class="kd-content k-mt-2 k-grow k-skeleton k-opacity-30 k-rounded-tl-md k-rounded-tr-md"></div>
  </div>

  <style>
    .kd-image-wrapper>.k-icon {
      font-size: 72px;
    }

    /* Breakpoints for full screen demo: max:599px, min:759px and max: 959 */
    @media (max-width: 678px),
    (min-width: 821px) and (max-width: 1038px),
    (min-width: 1241px) and (max-width: 1328px) {
      .kd-image-wrapper {
        display: none !important;
      }

      .kd-actions div {
        width: auto;
        flex-grow: 1;
      }

      .kd-content {
        margin-top: 24px;
      }
    }

    /* Breakpoint for full screen demo: max:359px */
    @media (max-width: 476px) {
      .kd-header {
        height: 100%;
      }

      .kd-header-core {
        display: flex;
        flex-direction: column;
        height: 100%;
      }

      .kd-actions {
        flex-direction: column;
      }

      .kd-actions>div {
        margin-left: 0;
        margin-top: 8px;
      }

      .kd-content {
        display: none;
      }
    }
  </style>

  <script>
    $(document).ready(function () {
      var dataSource = new kendo.data.DataSource({
        // data: Array.from(parent.___data, (item) => Object.assign({}, item)),
        data: parent.___data,
        sort: { field: "CityName", dir: "asc" }
      });

      $("#kd-place-chooser").kendoDropDownList({
        filter: "contains",
crossOrigin: "anonymous",
        optionLabel: 'Please select city...',
        dataTextField: "CityName",
        dataValueField: "CityID",
        dataSource: dataSource
      });
    });
  </script>
</body>

</html>
Rana
Top achievements
Rank 2
 updated question on 04 Aug 2023
0 answers
81 views

¿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>

andres
Top achievements
Rank 1
 asked on 13 Jul 2023
0 answers
74 views

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

Daniel
Top achievements
Rank 1
Iron
 asked on 13 Jun 2023
0 answers
48 views

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.

Vaibhav
Top achievements
Rank 1
Iron
 asked on 09 Apr 2023
0 answers
43 views

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?

Ataberk
Top achievements
Rank 1
 asked on 06 Mar 2023
0 answers
47 views

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!

n/a
Top achievements
Rank 1
 asked on 01 Mar 2023
Narrow your results
Selected tags
Tags
+? more
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?