I want to know where my json is incorrect... I know that there is a syntax error so please correct it for me.
({
ageRestriction: false,
allowedCountries: [
],
user: {
ip: '184.173.107.5',
name: ''
},
player: {
bufferTime: 60,
debug: false,
window: false,
panel: false,
autoplay: true,
smoothing: true,
scale: 'letterbox'/*none,
stretch,
letterbox,
zoom*/,
iframeControl: false
},
similar: {
path: '/actions/control/similaritems/50e54d84d681c00e603935e3',
preview: '//s.dogannet.tv/q/i/76/600x336/50e54e8cd681c00e603935e4'
},
watermark: {
path: '//s.dogannet.tv/n/s/content/images/watermark.png?v=2',
position: 'bottomright'
},
media: {
id: '50e54d84d681c00e603935e3',
controller: 'osmf',
defaultServiceUrl: 'http: //media.netd.com.tr',
serviceUrl: 'http: //37.48.66.141',
path: 'S1/HLS_VOD/5ea1_1536/index.m3u8?key=49bfee85b05d117a2906368428094e94&app=com.dcom&max=1500',
preview: '//s.dogannet.tv/q/i/76/1600x900/50e54e8cd681c00e603935e4'
},
playlog: {
callback: function(data){
data.Application='com.dcom';data.UserName='';data.SessionId='m443qmsgz3mdlnwing2h4qno';data.AnonymId='d241c910-6ae1-4f73-afc4-7cb5991517d4';data.ItemId='50e54d84d681c00e603935e3';data.Url='http: //www.netd.com/diziler/yerli/kanit/kanit-1-sezon/kanit-1-bolum';data.extraData={
'Agent': navigator.userAgent
};$.ajax({
type: "POST",
url: "http://stats.dogannet.tv/playlog.ashx",
data: data,
global: false,
async: true,
cache: false
});
}
},
heartbeat: {
interval: 10000,
callback: function(data){
data.Application='com.dcom';data.UserName='';data.SessionId='m443qmsgz3mdlnwing2h4qno';data.AnonymId='d241c910-6ae1-4f73-afc4-7cb5991517d4';data.ItemId='50e54d84d681c00e603935e3';data.Url='http: //www.netd.com/diziler/yerli/kanit/kanit-1-sezon/kanit-1-bolum';data.SessionId='m443qmsgz3mdlnwing2h4qno';data.extraData={
'Agent': navigator.userAgent
};$.ajax({
type: "POST",
url: "http://stats.dogannet.tv/heartbeat.ashx",
data: data,
global: false,
async: false,
cache: false
});
}
},
gemius: {
materialIdentifier: '1',
identifier: 'AfVAtKMRq0Ff4WlROmmKr7Po31j_P7s.VdXOiWt3SGL.x7',
hitCollector: 'http: //str.hit.gemius.pl'
},
comscore: {
c1: '1',
c2: '17476642'
},
advert: {
display: true,
skipShowDuration: 9,
preroll: 'http: //app.medyanetads.com/vast.a2?target=netd_videoad_arsivdizi_preroll&channel=50e54d84d681c00e603935e3&category=11534404&keywords=kanit,
prof_dr_sevil_atasoy,
engin_benli,
inci_demirkaya,
deniz_celiloglu&videoid=463_50e54d84d681c00e603935e3',
midroll: 'http: //app.medyanetads.com/vast.a2?target=netd_videoad_arsivdizi_midroll&channel=50e54d84d681c00e603935e3',
postroll: 'http: //app.medyanetads.com/vast.a2?target=netd_videoad_arsivdizi_postroll&channel=50e54d84d681c00e603935e3',
overlay: 'http: //app.medyanetads.com/vast.a2?target=netd_videoad_arsivdizi_overlay&channel=50e54d84d681c00e603935e3',
pauseroll: 'http: //app.medyanetads.com/vast.a2?target=netd_videoad_pauseroll&channel=50e54d84d681c00e603935e3',
viscaleShowDuration: 30,
viscaleRatio: 0.3889,
viscale: "http://app.medyanetads.com/vast.a2?target=netd_videoad_viscale&channel=52fddcab68f7320be461c2e9"
},
survey: {
display: true,
path: 'http: //app.medyanetads.com/survey/survey.swf',
domain: 'netd.com'
}
});
});
PLEASE CORRECT I dont know where is mistake. I wanted to correct it with http://jsonlint.com/ But I can't done
You should wrap your keys inside double quotes like this:
{
"ageRestriction": false,
"allowedCountries": [
],
"user": {
"ip": "184.173.107.5"
...
If your values are also strings, then they should also be inside double quotes, like in the example above.
See here the exact specification: http://www.json.org/
Related
How can I stop the kendo grid/datasource automatically posting changes to the server?
I've tried intercepting Grid's saveChanges but it isn't being triggered by the Updated command. As per the docs, DataSource's auto-sync by default should be false, but I went ahead and set it anyway but to no effect.
$("#items-grid").kendoGrid({
dataSource: {
autoSync: false,
type: "json",
transport: {
read: {
url: "#Html.Raw(Url.Action("
ItemList ", "
PurchaseRequisition ", new {prId = #Model.Id }))",
type: "POST",
dataType: "json",
},
update: {
url: "#Html.Raw(Url.Action("
ItemEdit ", "
PurchaseRequisition "))",
type: "POST",
dataType: "json",
}
},
sync: function(e) {
console.log("sync complete");
},
schema: {
data: "Data",
total: "Total",
errors: "Errors",
model: {
id: "Id",
fields: {
/...
}
}
},
},
saveChanges: function(e) {
// not fired from Update command
e.preventDefault();
},
columns: [{
// ...
}, {
command: [{
name: "edit",
text: {
edit: "Edit",
update: "Update",
cancel: "Cancel"
}
}],
width: 100
}]
});
});
You can try with dataSource batch set to true.
var dataSource = new kendo.data.DataSource({
transport: {...},
batch: true
...}
$("#grid").kendoGrid({
dataSource: dataSource,
navigatable: true,
pageable: true,
height: 550,
toolbar: ["create", "save", "cancel"],
columns: [...],
editable: true
});
NOTE: this is inline editing.
You can see an example on the official page: Batch editing
I am trying to apply sorting on all data when i click on Name but sorting operation is applied on first page data.
Here is my code.
$("#products-grid").kendoGrid({
dataSource: {
type: "json",
transport: {
read: {
url: "#Html.Raw(Url.Action("ProductList", "Product"))",
type: "POST",
dataType: "json",
data: additionalData
}
},
schema: {
data: "Data",
total: "Total",
errors: "Errors"
},
pageSize: #(defaultGridPageSize),
serverPaging: true,
// serverFiltering: true,
sort: { field: "Name", dir: "desc" },
},
pageable: true,
sortable: true,
editable: {
confirmation: "#T("Admin.Common.DeleteConfirmation")",
mode: "inline",
},
scrollable: false,
columns: [
{
field: "Name",
title: "#T("Admin.Catalog.Products.Fields.Name")",
sortable: {
initialDirection: "desc"
},
width: 300,
} ]
});
I have also tried with serverSorting: true but at that time default sorting not working.
Here is my code :
$.ajax({
url: 'dashboard/gender',
type: 'post',
async: true,
dataType: "json",
success: function (data) {
visitorData(data);
}
});
function visitorData (data) {
$('#gender-pie').highcharts({
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: 'Genders'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: false
},
showInLegend: true
}
},
series: data,
});
}
Here is the response : {"males":9,"females":2}
My controller is 200 ok. Passing data correctly . But data aren't biding inside my div . Title is displayed correctly .
Your JSON formatting for the series data is incorrect. It should be formatted like this:
series: [{
data: [{
name: 'Males',
y: 9
}, {
name: 'Females',
y: 2
}]
}]
Working JSFiddle example
I seem to be having an issue trying to bing my JSON result to my Kendo UI grid
This is my JSON result I get back from my web service:
"{
"Data":[{
"ModifiedBy":"Joe Blogs",
"ModifiedDate":"2015-04-27T00:00:00",
"Name":"One",
"Number":"201504260952",
"Status":"Draft",
"Id":3
},
{
"ModifiedBy":"Joe Blogs",
"ModifiedDate":"2015-07-08T11:04:00",
"Name":"fdasfdsa",
"Number":"20150708110209",
"Status":"Draft",
"Id":17},
{
"ModifiedBy":"Joe Blogs",
"ModifiedDate":"2015-07-09T08:44:00",
"Name":"Two",
"Number":"20150709084329",
"Status":"Draft",
"Id":20
}],
"Groups":null,
"Total":3
}"
This is my Grid and data source set up:
$(function () {
var myGrid = $("#myGrid");
myGrid.kendoGrid({
groupable: true,
sortable: true,
filterable: true,
pageable: {
refresh: true,
pageSizes: true,
buttonCount: 5
},
columns: [{
hidden: true,
field: "Id"
},
{
headerTemplate: ""
},
{
title: "Status",
field: "Status"
},
{
title: "Number",
field: "Number"
},
{
title: "Name",
field: "Name"
}]
});
var myDataSource = new kendo.data.DataSource({
transport: {
read: {
url: "/somewhere.svc/Data",
dataType: "json",
type: "GET"
}
},
schema: {
data: 'Data',
groups: 'Groups',
aggregates: 'Aggregates',
total: 'Total',
model: {
id: 'Id',
fields: {
Id: { type: 'number' },
Status: { type: 'string' },
Number: { type: 'string' },
Name: { type: 'string' },
ModifiedBy: { type: 'string' },
ModifiedDate: { type: 'date' }
}
}
},
pageSize: 5,
serverPaging: true,
serverGrouping: true,
serverSorting: true,
serverFiltering: true
});
myGrid.data("kendoGrid").setDataSource(myDataSource);
});
When the page loads I can see that I get the above JSON but I don't get any rows displayed in the grid.
What might I be doing wrong?
Another frustrating day with the Kendo Grid. Anyway, my problem is this: When I click "Edit" on a grid row item, it goes into edit mode. Good. Then I modify a record, and click update. I would expect the "/Company/SaveAccountAdmin" method to be called.But no... The read method is called again. When I click "Cancel" the record just disappears! The $("#save") click event is just an attempt to force a save, but surely these events can be triggered off the grid command buttons? Any ideas anyone?
/// <reference path="../kendo.all-vsdoc.js" />
$(document).ready(function () {
var CompanyId = $("#CompanyId").val();
var dataSource = new kendo.data.DataSource(
{
batch: true,
pageSize: 10,
transport: {
create: {
url: "/Company/SaveAccountAdmin",
contentType: "application/json; charset=utf-8",
type: "POST",
dataType: "json",
url: "/Company/ReadAccountAdmin",
},
read: {
url: "/Company/ReadAccountAdmin"
},
update: {
url: "/Company/SaveAccountAdmin",
contentType: "application/json; charset=utf-8",
type: "POST",
dataType: "json",
url: "/Company/ReadAccountAdmin",
},
//destroy: {},
parameterMap: function (options, operation) {
if (operation !== "read" && options.model) {
return { model: kendo.stringify(options.model) };
}
}
},
schema: {
model: {
id: "ComanyContactId",
fields: {
CompanyId: { type: "number", editable: false, nullable: false, defaultVaue: CompanyId },
CompanyContactId: { type: "number", editable: false, defaultValue: 0 },
FirstName: { type: "string", nullable: false, validation: { required: true } },
LastName: { type: "string", nullable: false, validation: { required: true } },
Email: { type: "string", nullable: false, validation: { required: true } },
Phone: { type: "string", nullable: false, validation: { required: true } },
IsActive: { type: "boolean" }
}
}
}
});
$("#save").click(function (event) {
event.preventDefault();
var rows = $.map(dataSource.data(), function (value, index) {
return {
CompanyId: value["CompanyId"],
CompanyContactId: value["CompanyContactId"],
FirstName: value["FirstName"],
LastName: value["LastName"],
Email: value["Email"],
Phone: value["Phone"],
IsActive: value["IsActive"]
}
});
var jsonCompanyContacts = JSON.stringify(rows);
$.ajax({
url: '/Company/SaveAccountAdmin',
type: 'POST',
traditional: true,
data: { "jsonCompanyContacts": jsonCompanyContacts },
success: alert("Data Saved")
})
});
$("#AccountAdmins").kendoGrid({
dataSource: dataSource,
toolbar: ["create"],
editable: "inline",
sortable: true,
pageable: true,
navigatable: true,
editable: "inline",
columns: [
{ field: "CompanyId", title: "CompanyID", sortable: true },
{ field: "CompanyContactId", title: "Company ContactID", sortable: true },
{ field: "FirstName", title: "First Name", sortable: true },
{ field: "LastName", title: "Last Name" },
{ field: "Email", title: "Email", },
{ field: "Phone", title: "Phone", },
{ field: "IsActive", title: "Is Active" },
{ command: ["edit", "destroy"], title: " ", width: "210px" }]
});
});
My guess is that it is because you have the Read URL set for the Update command:
update: {
url: "/Company/SaveAccountAdmin", // <-- Not used because it is changed below
contentType: "application/json; charset=utf-8",
type: "POST",
dataType: "json",
url: "/Company/ReadAccountAdmin", // <-- Read URL set
},