Kendo Column chart not showing any column,after publishing website on IIS - asp.net-mvc

Im getting crazy over this issue,on my browser and my computer I can see the chart and and its columns ,but after publishing on IIS ,data is there but ,empty chart!,its not a complicated thing but i am wondering why this happen,im sending data as a JSON,i have also checked there if all my javascript file has been copied in the IIS ,all is ok,here is my controller:
List<FaultStatErrorIdViewModel> erro_id = new List<FaultStatErrorIdViewModel>();
foreach (DataRow dr in dt_error.Rows)
{
FaultStatErrorIdViewModel _error = new FaultStatErrorIdViewModel();
_error.cur_year = dr["cur_year"].ToString();
_error.error_dur = dr["error_duration_this_year"].ToString();
_error.m_error_id = dr["m_error_id"].ToString();
erro_id.Add(_error);
}
return Json(erro_id, JsonRequestBehavior.AllowGet);
Here is my chart:
$.ajax({
dataType: "json",
type: "POST",
url: "#Url.Action("faultStatErrorId","Ranking")",
contentType: "application/json; charset=utf-8",
data: JSON.stringify({ "regionalManager": tmpString,"error_name":itemname, "dtFrom": dtFrom, "dtTo": dtTo }),
success: function (rslt) {
$("#error_id_Chart").kendoChart({
dataSource: {
data: rslt
},
title: {
text: "Main-Group:" + itemname,
position: "bottom",
},
chartArea: {
background: "#fcfcfc",
width: 700,
},
series: [{
// data: finaldata,
type: "column",
name: "DURATION",
color: "blue",
field: "error_dur",
categoryField: "m_error_id",
}],
legend: {
visible: false
},
valueAxes: {
name: "Duration",
title: { text: "Duration (Hrs)" },
majorGridLines: {
visible: false
},
line: {
visible: true
},
},
tooltip: {
visible: true,
// majorUnit:10,
template: " #= value #"
},
});
}
});

Related

Bind data to grid after page load MVC

I have problem here.With kendo grid i'm loading data from some action in controller.But in the last column i have link which should fire another action in same controller.When i delete this piece of code
type: "json",
transport: {
read: {
url: "#Html.Raw(Url.Action("ListFinances", "Jobs"))",
type: "POST",
dataType: "json",
data: additionalData
},
},
schema: {
data: "Data",
total: "Total",
errors: "Errors"
},
last column is working perfect,bit when is present this piece of code, last column is not working>please here some help, i;m new to mvc.Below is the code:
$("#jobs-grid").kendoGrid({
dataSource: {
data: #Html.Raw(JsonConvert.SerializeObject(Model.FinishedJobs)),
schema: {
model: {
fields: {
JobNumber: { type: "string" },
CustomerId: { type: "number" },
JobCount: { type: "number" },
JobYear: { type: "number" },
Status: { type: "number" },
Position: { type: "number" },
Finished: { type: "boolean" },
HasInvoice: { type: "boolean" },
}
}
},
type: "json",
transport: {
read: {
url: "#Html.Raw(Url.Action("ListFinances", "Jobs"))",
type: "POST",
dataType: "json",
data: additionalData
},
},
schema: {
data: "Data",
total: "Total",
errors: "Errors"
},
error: function(e) {
display_kendoui_grid_error(e);
// Cancel the changes
this.cancelChanges();
},
pageSize: 20,
serverPaging: true,
serverFiltering: true,
serverSorting: true
},
//dataBound: onDataBound,
columns: [
#*{
field: "Status",
title: "Status",
template: '#= Status #'
},*#
{
field: "JobNumber",
title: "jobNumber",
template: '#= JobNumber #'
},
{
field: "CustomerId",
title: "Customer",
template: '#= Customer.Name #'
},
{
field: "Id",
title: "Id"
},
#*{
field: "ShortDesc",
title: "ShortDesc"
},*#
{
field: "DateCompletition",
title: "DateCompletition"
},
{
field: "Id",
title: "#T("Common.Edit")",
width: 130,
template: 'Edit'
}
],
pageable: {
refresh: true,
pageSizes: [5, 10, 20, 50]
},
editable: {
confirmation: false,
mode: "inline"
},
scrollable: false,
// sortable: true,
// navigatable: true,
// filterable: true,
// scrollable: true,
selectable: true
});
});
</script>
It seems you want to add a command to the grid, The way to add a command as described here is as follows
var grid = $("#jobs-grid").kendoGrid({
dataSource: {
pageSize: 20,
data: #Html.Raw(JsonConvert.SerializeObject(Model.FinishedJobs)),
},
pageable: true,
height: 550,
columns: [
{ field: "JobNumber", title: "JobNumber", width: "140px" },
{ field: "CustomerId", title: "Customer", width: "140px" },
{ field: "Id", title:"Id" },
{ field: "DateCompletition", title:"DateCompletition" },
{ command: { text: "Edit",
click: function(e){
// here you can add your code
}},
title: " ",
width: "180px" }]
}).data("kendoGrid");
You might have a look on the documentation of the kendo grid here
Hope this will help you

kendo ui Grid "Popup mode" ,Edit And Delete Button, Not firing the Controller Action

This is My view with kendo ui grid, It's Read function firing just fine, but the problem just begins when I want to update,
The update Function in my controller Not even Firing,
<script>
$(document).ready(function () {
var dataSource = {
transport: {
type: "json",
read: {
url: "#Html.Raw(Url.Action("CommentList", "Comment"))",
type: "POST",
dataType: "json"
},
update: {
url: "#Html.Raw(Url.Action("CommentUpdate", "Comment"))",
type: "POST",
dataType: "json"
},
destroy: {
url: "#Html.Raw(Url.Action("CommentDelete", "Comment"))",
type: "POST",
dataType: "json"
}
},
schema: {
data: "Data",
total: "Total",
errors: "Errors",
model: {
id: "Id",
fields: {
Id: { type: "number" },
ProductName: { editable: false, type: "string"},
ProductPicture: { editable: false, type: "string"},
Text: { editable: false, type: "string"},
AdminConfirm: { editable: true, type: "boolean", validation: { required: true } }
}
}
},
requestEnd: function (e) {
if (e.type === "create" || e.type === "update") {
this.read();
}
},
error: function (e) {
alert("something wrong!");
// Cancel the changes
this.cancelChanges();
},
pageSize: 15,
serverPaging: true,
serverFiltering: true,
serverSorting: true
};
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: {
refresh: true,
pageSizes: [10, 15, 20, 30, 50]
},
height: 550,
columns: [
{
field: "ProductName",
title: "product name",
width: "90px"
},
{
field: "ProductPicture",
title: "picture",
width: "100px",
},
{
field: "Text",
title: "comment",
width: "180px"
},
{
field: "AdminConfirm",
title: "adminconfirm",
width: "70px",
},
{
command: [
{
name: "edit" , text: { // sets the text of the "Edit", "Update" and "Cancel" buttons
edit: "edit",
update: "update",
cancel: "cancel"
}
}
],
title: " ", width: "250px"
}
],
editable : {
mode : "popup",
window : {
title: "confirmation form"
}}
});
});
</script>
</div>
This is My first line of update Function
[HttpPost]
public ActionResult CommentUpdate(DataSourceRequest request, CommentViewModel comment)
Anybody Know Why?
Thanx in Advance

Can we set bar labels with dynamic custom array in Highcharts?

I think this is bug in the library.
I want a custom labels on each bar, but it is not working!
var options = {
chart: {
type: 'column'
},
plotOptions: {
series: {
stacking: 'normal',
dataLabels: {
enabled: true,
formatter: function() {
if (this.series.options.myLabels) {
return "XXX: " + this.series.options.myLabels[this.point.x];
}
}
}
}
},
exporting: {
url: 'http://export.highcharts.com/',
chartOptions: {
yAxis: {
labels: {
style: {
color: 'green'
}
}
}
}
},
yAxis: {
labels: {
style: {
color: 'red'
},
format: '{value:,.0f}'
}
},
series: [{
type: 'column',
data: [10000, 20000, 8000],
myLabels: ["A", "B", "C"]
}, {
type: 'column',
data: [10000, 2000, 10000]
}, {
type: 'spline',
data: [5000, 15000, 5000]
}
]
};
var globals = {
lang: {
thousandsSep: ','
}
}
$('#export').click(function() {
var obj = {},
exportUrl = options.exporting.url;
obj.options = JSON.stringify(options);
obj.globaloptions = JSON.stringify(globals);
obj.type = 'image/png';
obj.async = true;
$.ajax({
type: 'post',
url: exportUrl,
data: obj,
success: function(data) {
var imgContainer = $("#imgContainer");
$('<img>').attr('src', exportUrl + data).attr('width', '450px').appendTo(imgContainer);
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="export">get image</button>
<div id="imgContainer"></div>
JSON is not a bug, because you cannot place the function inside the json. Functions are not executable and are skipped. So you need to use the callback and there place your function in series.update();
Fixed demo:
- http://jsfiddle.net/ayyunrb4/

Kendo UI Grid update event is not firing

I have Kendo UI inline Grid. It read and populate the grid properly. but when i press edit and changes in any column and press update then update event is not firing.
and it also not calling controller method.
Hope someone can help me point out what I am doing wrong here.
following is my grid binding.
dataSource = new kendo.data.DataSource({
transport: {
read: function (options) {
$.ajax({
type: 'POST',
url: "./GetIngredients",
dataType: "json",
success: function (result) {
options.success(result);
}
});
},
update: function (options) {
$.ajax({
type: 'POST',
url: "./UpdateData",
dataType: "json",
contentType: "application/json; charset=utf-8"
});
},
parameterMap: function (options, operation) {
alert('1');
if (operation !== "read" && options.models) {
alert('2');
return { models: kendo.stringify(options.models) };
}
}
},
batch: true,
pageSize: 20,
schema: {
model: {
id: "Id",
fields: {
Id: { editable: false, nullable: true },
Division: { type: "string", editable: true, nullable: false },
GroupName: { type: "string", validation: { required: true } },
CategoryName: { type: "string" },
TypeName: { type: "string" },
ItemName: { type: "string" }
}
}
}
});
var grid = $("#grid").kendoGrid(
{
dataSource: dataSource,
height: 430,
scrollable: true,
pageable: true,
navigatable: true,
columns: [
{ field: "Division", title: "Division", width: "80px" },
{ field: "GroupName", title: "Group Name", width: "70px" },
{ field: "CategoryName", title: "Category Name", width: "110px" },
{ field: "TypeName", title: "Type Name", width: "100px" },
{ field: "ItemName", width: "140px" },
{ command: ["edit", "destroy"], title: " ", width: "170px" }],
editable: "inline"
}).data("kendoGrid");
following is the method in Homecontroller.
[HttpPost]
public JsonResult GetIngredients()
{
IngredientData ingredientData = new IngredientData();
ingredientData.Id = 1;
ingredientData.DivisionId = 1;
ingredientData.Division = "Division Abc";
ingredientData.GroupId = 2;
ingredientData.GroupName = "Group -A";
ingredientData.CategoryId = 3;
ingredientData.CategoryName = "Category -D";
ingredientData.FoodTypeId = 4;
ingredientData.TypeName = "Type One";
ingredientData.ItemId = 5;
ingredientData.ItemName = "Item One";
return Json( ingredientData , JsonRequestBehavior.AllowGet);
}
[HttpPost]
public void UpdateData()
{
// logic for update data in database.
}
Did you realize that you have batch set to true? When in batch mode, you have to invoke sync on dataSource or saveChanges in Grid definition.
Try adding a toolbar command for invoking saveChanges as follow:
var grid = $("#grid").kendoGrid({
dataSource: dataSource,
height: 430,
scrollable: true,
pageable: true,
navigatable: true,
toolbar: [ "save" ],
columns: [
{ field: "Division", title: "Division", width: "80px" },
{ field: "GroupName", title: "Group Name", width: "70px" },
{ field: "CategoryName", title: "Category Name", width: "110px" },
{ field: "TypeName", title: "Type Name", width: "100px" },
{ field: "ItemName", width: "140px" },
{ command: ["edit", "destroy"], title: " ", width: "170px" }],
editable: "inline"
}).data("kendoGrid");
or simply remove batch mode.
I have faced same issue. But I have solved using this.
To fire create/delete/update we need to specify schema in dataSource( in schema we should mention atleast what is id field).
schema: {
model: {
id: "StudentID"
}
}
Code:
var dataSource = new kendo.data.DataSource({
transport: {
read: function (options) {
alert("read");
},
create: function (options) {
alert("create");
},
update: function (options) {
alert("update"); },
destroy: function (options) {
alert("destroy"); }
},
schema: {
model: {
id: "StudentID"
}
}

kendoui grid only use create (no delete or update)

$("#grid").kendoGrid({
dataSource: {
transport: {
read: function(options) {
$.ajax( {
url: "/api/mygetfunction",
data: options.data,
success: function(result) {
options.success(result);
}
});
},
update: function (options) {
$.ajax({
url: "/api/myupdatefunction",
data: options.data,
success: function (result) {
options.success(result);
}
});
},
destroy: function (options) {
$.ajax({
url: "/api/mydestroyfunction",
data: options.data,
success: function (result) {
options.success(result);
}
});
},
create: function (options) {
$.ajax({
url: "/api/mycreatefunction",
type: 'POST',
data: ...
});
},
parameterMap: function (options, operation) {
if (operation !== "read") {
return JSON.stringify(options);
}
}
},
schema: {
id: "Id",
model: {
fields: {
Id: { type: "string" },
Description: { type: "string" }
}
}
},
pageSize: 10,
serverPaging: false,
serverFiltering: false,
serverSorting: false,
batch: false
},
toolbar: ["create"],
filterable: true,
sortable: true,
pageable: true,
columns: [
{
field: "Description",
title: "Description"
},
{ command: ["edit", "destroy"], title: " ", width: "210px" }
],
editable: "inline"
});
The grid has 3 rows. When I click on edit, I change the description column. Then I Click Update, and the grid caals the 'create' of the transport configuration. I've set batch to false, and strangely, there are 3 create's instead of the changed row.
What's the reason the editing of the grid causes a create instead of update?
This may happen if your records don't have an Id field properly set. The data source considers all records that don't have id to be "new".

Resources