I recently came across a strange issue happening with the kendo Scheduler regarding firing off change events.
I have a custom event handler set so that when a user clicks on an item in the Scheduler it opens a link to a separate details page (in a new tab). The problem is that after doing this, other (unrelated) UI elements in the Scheduler will fire off the exact same event when I click on them.
You can actually see this behavior on the Scheduler Events sample page here: http://demos.telerik.com/kendo-ui/scheduler/events
To replicate:
Click on the Month View button.
Click on (highlighting) the item "HR Lecture", on the 06th. This will fire off a Change event.
Now click on the Month View button again. In between the dataBinding and dataBound events, another Change event will fire off for the same time slot. (Prior to clicking on HR Lecture, this is not the case. You'll only see events for navigation, dataBinding, and dataBound events)
This doesn't seem to happen with all events, HR Lecture just appears to be one that *does* trigger the behavior.
Is this expected? If so, is there any way to prevent this from happening?
Hi all,
I am trying to display an object in a Kendo grid in a MVC Website, however this object contains a dictionary and it seems like the grid is unable serialize it.
This is the error message I am getting:
Type 'System.Collections.Generic.Dictionary`2[[ExactModels.SalesOrderLine, ExactModels, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[ExactModels.Item, ExactModels, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' is not supported for serialization/deserialization of a dictionary, keys must be strings or objects.
I am using Kendo.Mvc.dll version 2015.2.902.545.
And this is the object which contains the dictionary that is causing the problem.
public class CustomOrder
{
[Key]
public Guid ID { get; set; }
//public SalesOrder salesOrder { get; set; }
private SalesOrder order;
public SalesOrder salesOrder
{
get { return order; }
set
{
order = value;
if (order != null)
{
this.ID = order.OrderID;
}
}
}
public Account account { get; set; }
public Dictionary<
SalesOrderLine
, Item> salesOrderLineItem { get; set; }
public Boolean Checked { get; set; }
}
Anyone any idea of how to fix this?
Thanks in advance.
Please find the below code as i want to set default value of dropdown instead of optionlable from JSON data which is returned
from controller .
Please find the below code
public ActionResult GetOrders()
{
List<usp_IDQ_GetLicenseDistrictsVO> objresult1 = new List<usp_IDQ_GetLicenseDistrictsVO>();
objresult1 = objConnection.usp_IDQ_GetLicenseDistricts(User.Identity.Name, true).ToList();
return Json(objresult1, JsonRequestBehavior.AllowGet); ;
}
@(Html.Kendo().DropDownList()
.Name("DropDownList1")
//.Events(ev => ev.DataBound("SalesPersonID_DataBound"))
.OptionLabel("Select ...")
.HtmlAttributes(new { style = "width:300px" })
.OptionLabel("Select ...")
.DataTextField("District_Id")
.DataValueField("Location_ID")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetOrders", "IDTDashboard");
})
.ServerFiltering(true);
})
.AutoBind(false)
I would like to setup a validation rule that would conditionally be applied. For example
I have three fields
Status: Enum field (​pending, approved, denied)
Denied Code: (price, qty, misc..., ect...)
Comment (Long text)
So if the Status is equal to denied I want the Denied Code and Comment to require an update otherwise ignore them. Is this possible? and if so how would I go about doing this? Also the value of the Denied Code must not equal none.
My Index page:
<
style
>
.cont {
padding-right: 10%;
padding-left: 10%;
margin-right: auto;
margin-left: auto;
}
</
style
>
<
div
class
=
"cont"
>
 @(Html.Kendo().Grid<
Portal.Model.DAX.PurchaseJournalTransaction
>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(c => c.PurchId).Title("Order Id").Width(120);
columns.Bound(c => c.LineNum).Title("Line").Width(80).Hidden(true).IncludeInMenu(true);
columns.Bound(c => c.ItemId).Width(120);
columns.Bound(c => c.ExternalItemId).Title("External Id").Width(120);
columns.Bound(c => c.Name).Width(400);
columns.Bound(c => c.DeliveryDate).Width(140).Format("{0:MM/dd/yy}");
columns.Bound(c => c.PurchUnit).Width(75).Title("Unit");
columns.Bound(c => c.Quantity).Width(120).Format("{0:#,##0}");
columns.Bound(c => c.PurchasePrice).Width(100).Title("Price").Format("{0:$ #,##0.00}");
columns.Bound(c => c.LineAmount).Width(160).Hidden(true).IncludeInMenu(true).Format("{0:$ #,##0.00}");
columns.Bound(c => c.LineDiscount).Width(80).Hidden(true).IncludeInMenu(true);
columns.Bound(c => c.LinePercent).Width(80).Hidden(true).IncludeInMenu(true);
columns.Bound(c => c.ApprovalStatus).Width(130).EditorTemplateName("ApprovalStatusEditor").Title("Status");
columns.ForeignKey(c => c.ApprovalReasonId, (System.Collections.IEnumerable)ViewData["ApprovalReason"], "Id", "Description").Width(350).Title("Denied Code");
})
.ToolBar(toolbar =>
{
toolbar.Excel();
toolbar.Save();
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Pageable(p => p.PageSizes(true).PageSizes(new int[] {20,50,100,1000}))
.Navigatable()
.Filterable(filtering => filtering.Enabled(true))
.Groupable()
.Sortable(s => {
s.SortMode(GridSortMode.MultipleColumn);
s.AllowUnsort(true);
})
.ColumnMenu()
.Scrollable(scrollable => {
scrollable.Enabled(true);
scrollable.Height(700);
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Model(model => {
model.Id(p => p.CompanyId);
model.Field(c => c.PurchId).Editable(false);
model.Field(c => c.LineNum).Editable(false);
model.Field(c => c.ItemId).Editable(false);
model.Field(c => c.ExternalItemId).Editable(false);
model.Field(c => c.Name).Editable(false);
model.Field(c => c.CurrencyCode).Editable(false);
model.Field(c => c.PriceUnit).Editable(false);
model.Field(c => c.Quantity).Editable(false);
model.Field(c => c.PurchUnit).Editable(false);
model.Field(c => c.PurchasePrice).Editable(false);
model.Field(c => c.DeliveryDate).Editable(false);
model.Field(c => c.LineAmount).Editable(false);
model.Field(c => c.LineDiscount).Editable(false);
model.Field(c => c.LinePercent).Editable(false);
})
.Read(read => read.Action("PurchaseJournalTransactions_Read", "Approval"))
.Update(update => update.Action("PurchaseJournalTransactions_Update", "Approval"))
)
)
<
br
/>
</
div
>
Hello, I just started working with the product. I created a grid using the MVC control. Also, the grid is using a custom pop up form when editing/creating a record.
Inside that custom form, I added a multiselect control. The control should reference values stored in a child table from the record, basically I want to store multiples agencies a person can belong to. The model have a reference to the child table.
When submitting the form, the entity object knows that I ​selected X amount of companies, but I cant get to the values. What is the best way of doing this for a child table?
<label for="Agency" class="required col-sm-3 control-label" style="text-align:left;margin-right:-55px">Insurance Companies</label>
@(Html.Kendo().MultiSelect()
.Name("tblAgentInsurers")
.DataTextField("InsuranceAgencyName")
.DataValueField("InsuranceAgencyID")
.Placeholder("Select agencies...")
.HtmlAttributes(new { @class = "col-sm-2 form-control", style = "width:70%; height:auto; min-height: 34px;" })
.AutoBind(false)
.Filter(FilterType.Contains)
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetAgencies", "Agents");
})
.ServerFiltering(true);
})
)​
Hi
I have textbox, a button and a Grid in my screen, i am binding data to it on a button click with the textbox input.
If the user clicks the button again with different inputs, i have to go to DB, get data and append the new data to the existing Grid data.
I should not lose the existing data and i need to append new data to the same grid I should be able to call the same URL to get data.
Please let me know how I can achieve this.
Sample Code:
<input type="text" class="k-textbox"/>
<button id="btnAdd">Add</button></td>
<div id="grid"></div>
<script>
$("#btnAdd").on('click', function () {
$("#grid").kendoGrid({
dataSource: {
type: "json",
transport: {
read:
{
url: // my url with textbox inputs,
cache: false
}
},
schema: {
model: {
fields: {
ID: {type: "string"},
Name: {type: "String"}
}
}
},
columns: [
//{ hidden: true, field: "AssetID", editable: false },
{ template: "<input type='checkbox' class='checkbox' />" },
{ field: "ID"},
{ field: "Name"}]
}).data("kendoGrid");
});
});
</script>
I have a Project that uses Entity Framework as it data source, and I have a Kendo grid for that data set.
The Grid populates find while running from my development box but when I publish it; it just spins and nothing happens no error "nothing".
I have confirmed that the published page is talking to the Database as I can create a normal Model and for loop and return the data into a default div list. The query generated for the page does take about 3-4 seconds to process which I really can't speed up due to the size of the tables, it only returns though at most 100 records.
Below is the Index page
<
style
>
.cont {
padding-right: 10%;
padding-left: 10%;
margin-right: auto;
margin-left: auto;
}
</
style
>
<
div
class
=
"cont"
>
@(Html.Kendo().Grid<
Portal.Model.DAX.PurchaseJournalTransaction
>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(c => c.PurchId);
columns.Bound(c => c.LineNum).Visible(false);
columns.Bound(c => c.ItemId).Width(100);
columns.Bound(c => c.ExternalItemId);
columns.Bound(c => c.Name);
columns.Bound(c => c.DeliveryDate).Format("{0:MM/dd/yy}");
columns.Bound(c => c.CurrencyCode).Visible(false);
columns.Bound(c => c.PriceUnit).Visible(false);
columns.Bound(c => c.Quantity).Format("{0:#,##0}");
columns.Bound(c => c.PurchUnit).Locked();
columns.Bound(c => c.PurchasePrice).Format("{0:$#,##0.00}");
columns.Bound(c => c.PurchaseMarkup).Visible(false);
columns.Bound(c => c.DiscountPercentage).Visible(false);
columns.Bound(c => c.DiscountAmount).Visible(false);
columns.Bound(c => c.LineAmount).Visible(false);
columns.Bound(c => c.Dimension1).Visible(false);
columns.Bound(c => c.Dimension2).Visible(false);
columns.Bound(c => c.Dimension3).Visible(false);
columns.Bound(c => c.TaxAmount).Visible(false);
columns.Bound(c => c.TaxWriteCode).Visible(false);
columns.Bound(c => c.MultiLineDiscount).Visible(false);
columns.Bound(c => c.MultiLinePercent).Visible(false);
columns.Bound(c => c.LineDiscount).Visible(false);
columns.Bound(c => c.LinePercent).Visible(false);
columns.Bound(c => c.TaxGroup).Visible(false);
columns.Bound(c => c.TaxItemGroup).Visible(false);
columns.Bound(c => c.OriginalPurchId).Visible(false);
columns.Bound(c => c.InventDimId).Visible(false);
columns.Bound(c => c.InventQuantity).Visible(false);
columns.Bound(c => c.LineAmountTax).Visible(false);
columns.Bound(c => c.LineHeader).Visible(false);
columns.Bound(c => c.RecVersion).Visible(false);
columns.Bound(c => c.RecId).Visible(false);
columns.Bound(c => c.Dimension4).Visible(false);
columns.Bound(c => c.Source).Visible(false);
columns.Bound(c => c.ApprovalUserId).Visible(false);
columns.Bound(c => c.ApprovalDate).Visible(false);
columns.Bound(c => c.ApprovalStatus).EditorTemplateName("ApprovalStatusEditor");
//columns.Command(command => { command.Edit(); }).Width(180);
})
.ToolBar(toolbar =>
{
toolbar.Excel();
toolbar.Save();
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Pageable()
.Navigatable()
.Filterable()
.Groupable()
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => {
model.Id(p => p.CompanyId);
model.Field(c => c.PurchId).Editable(false);
model.Field(c => c.LineNum).Editable(false);
model.Field(c => c.ItemId).Editable(false);
model.Field(c => c.ExternalItemId).Editable(false);
model.Field(c => c.Name).Editable(false);
model.Field(c => c.CurrencyCode).Editable(false);
model.Field(c => c.PriceUnit).Editable(false);
model.Field(c => c.Quantity).Editable(false);
model.Field(c => c.PurchUnit).Editable(false);
model.Field(c => c.PurchasePrice).Editable(false);
model.Field(c => c.DeliveryDate).Editable(false);
})
.Read(read => read.Action("PurchaseJournalTransactions_Read", "Approval"))
.Update(update => update.Action("PurchaseJournalTransactions_Update", "Approval"))
)
)
<
br
/>
</
div
>
And here is the Controller:
using
Microsoft.AspNet.Identity;

using
System;
using
System.Collections.Generic;
using
System.Data;
using
System.Data.Entity;
using
System.Linq;
using
System.Net;
using
System.Web;
using
System.Web.Mvc;
using
Kendo.Mvc.Extensions;
using
Kendo.Mvc.UI;
using
Portal.Model.DAX;
namespace
Portal.Views
{
[Authorize(Roles=
"Vendor"
)]
public
class
ApprovalController : Controller
{
private
DAXContext db =
new
DAXContext();
public
ActionResult Index()
{
return
View();
}
public
ActionResult PurchaseJournalTransactions_Read([DataSourceRequest]DataSourceRequest request)
{
DataSourceResult result;
IQueryable<PurchaseJournalTransaction> purchasejournaltransactions;
string
UserId = User.Identity.GetUserId();
//"ffd508d2-10e1-4b34-b1e1-f35862d90b70";
try
{
purchasejournaltransactions =
from userVendor
in
db.UserVendors
join vendor
in
db.Vendors on
new
{ userVendor.CompanyId, userVendor.VendId }
equals
new
{ vendor.CompanyId, vendor.VendId }
join journal
in
db.PurchaseJournals on
new
{ p1 = (
string
)vendor.CompanyId, p2 = (
string
)vendor.VendId }
equals
new
{ p1 = (
string
)journal.CompanyId, p2 = (
string
)journal.OrderAccount }
join tran
in
db.PurchaseJournalTransactions on
new
{ p1 = (
string
)journal.CompanyId, p2 = (DateTime)journal.PurchaseOrderDate, p3 = (
string
)journal.PurchaseOrderId, p4 = (
string
)journal.PurchId }
equals
new
{ p1 = (
string
)tran.CompanyId, p2 = (DateTime)tran.PurchaseOrderDate, p3 = (
string
)tran.PurchaseOrderId, p4 = (
string
)tran.PurchId }
where
userVendor.UserId == UserId
&& tran.PurchaseLine.RemainPurchPhysical != 0
&& tran.PurchaseLine.Purchase.PurchaseTypeId == 3
select tran;
result = purchasejournaltransactions.ToDataSourceResult(request, purchaseJournalTransaction =>
new
{
CompanyId = purchaseJournalTransaction.CompanyId,
PurchaseOrderDate = purchaseJournalTransaction.PurchaseOrderDate,
PurchaseOrderId = purchaseJournalTransaction.PurchaseOrderId,
InventTransId = purchaseJournalTransaction.InventTransId,
PurchId = purchaseJournalTransaction.PurchId,
LineNum = purchaseJournalTransaction.LineNum,
ExternalItemId = purchaseJournalTransaction.ExternalItemId,
Item = purchaseJournalTransaction.Item,
ItemId = purchaseJournalTransaction.ItemId,
Name = purchaseJournalTransaction.Name,
CurrencyCode = purchaseJournalTransaction.CurrencyCode,
Quantity = purchaseJournalTransaction.Quantity,
LineAmount = purchaseJournalTransaction.LineAmount,
ApprovalDate = purchaseJournalTransaction.ApprovalDate,
ApprovalStatus = purchaseJournalTransaction.ApprovalStatus,
PurchUnit = purchaseJournalTransaction.PurchUnit,
PurchasePrice = purchaseJournalTransaction.PurchasePrice,
PriceUnit = purchaseJournalTransaction.PriceUnit,
PurchaseMarkup = purchaseJournalTransaction.PurchaseMarkup,
DiscountPercentage = purchaseJournalTransaction.DiscountPercentage,
DiscountAmount = purchaseJournalTransaction.DiscountAmount,
Dimension1 = purchaseJournalTransaction.Dimension1,
Dimension2 = purchaseJournalTransaction.Dimension2,
Dimension3 = purchaseJournalTransaction.Dimension3,
TaxAmount = purchaseJournalTransaction.TaxAmount,
TaxWriteCode = purchaseJournalTransaction.TaxWriteCode,
MultiLineDiscount = purchaseJournalTransaction.MultiLineDiscount,
MultiLinePercent = purchaseJournalTransaction.MultiLinePercent,
LineDiscount = purchaseJournalTransaction.LineDiscount,
LinePercent = purchaseJournalTransaction.LinePercent,
TaxGroup = purchaseJournalTransaction.TaxGroup,
TaxItemGroup = purchaseJournalTransaction.TaxItemGroup,
OriginalPurchId = purchaseJournalTransaction.OriginalPurchId,
DeliveryDate = purchaseJournalTransaction.DeliveryDate,
InventDimId = purchaseJournalTransaction.InventDimId,
InventQuantity = purchaseJournalTransaction.InventQuantity,
LineAmountTax = purchaseJournalTransaction.LineAmountTax,
LineHeader = purchaseJournalTransaction.LineHeader,
RecVersion = purchaseJournalTransaction.RecVersion,
RecId = purchaseJournalTransaction.RecId,
Dimension4 = purchaseJournalTransaction.Dimension4,
Source = purchaseJournalTransaction.Source,
ApprovalUserId = purchaseJournalTransaction.ApprovalUserId,
ApprovalReasonId = purchaseJournalTransaction.ApprovalReasonId,
});
return
Json(result);
}
catch
(Exception ex)
{
throw
new
HttpException(ex.InnerException.ToString());
}
}
[AcceptVerbs(HttpVerbs.Post)]
public
ActionResult PurchaseJournalTransactions_Update([DataSourceRequest]DataSourceRequest request, PurchaseJournalTransaction purchaseJournalTransaction)
{
if
(ModelState.IsValid)
{
var entity =
new
PurchaseJournalTransaction();
entity = db.PurchaseJournalTransactions.FirstOrDefault(t => t.PurchaseOrderId == purchaseJournalTransaction.PurchaseOrderId &&
t.PurchaseOrderDate == purchaseJournalTransaction.PurchaseOrderDate &&
t.PurchId == purchaseJournalTransaction.PurchId &&
t.InventTransId == purchaseJournalTransaction.InventTransId &&
t.CompanyId == purchaseJournalTransaction.CompanyId
);
//entity.CompanyId = purchaseJournalTransaction.CompanyId;
//entity.PurchaseOrderId = purchaseJournalTransaction.PurchaseOrderId;
//entity.PurchaseOrderDate = purchaseJournalTransaction.PurchaseOrderDate;
//entity.PurchId = purchaseJournalTransaction.PurchId;
//entity.InventTransId = purchaseJournalTransaction.InventTransId;
//entity.LineNum = purchaseJournalTransaction.LineNum;
//entity.ItemId = purchaseJournalTransaction.ItemId;
//entity.ExternalItemId = purchaseJournalTransaction.ExternalItemId;
//entity.Name = purchaseJournalTransaction.Name;
//entity.CurrencyCode = purchaseJournalTransaction.CurrencyCode;
//entity.Quantity = purchaseJournalTransaction.Quantity;
//entity.PurchUnit = purchaseJournalTransaction.PurchUnit;
//entity.PurchaseMarkup = purchaseJournalTransaction.PurchaseMarkup;
//entity.PurchasePrice = purchaseJournalTransaction.PurchasePrice;
//entity.DiscountPercentage = purchaseJournalTransaction.DiscountPercentage;
//entity.DiscountAmount = purchaseJournalTransaction.DiscountAmount;
//entity.LineAmount = purchaseJournalTransaction.LineAmount;
//entity.Dimension1 = purchaseJournalTransaction.Dimension1;
//entity.Dimension2 = purchaseJournalTransaction.Dimension2;
//entity.Dimension3 = purchaseJournalTransaction.Dimension3;
//entity.TaxAmount = purchaseJournalTransaction.TaxAmount;
//entity.TaxWriteCode = purchaseJournalTransaction.TaxWriteCode;
//entity.MultiLineDiscount = purchaseJournalTransaction.MultiLineDiscount;
//entity.MultiLinePercent = purchaseJournalTransaction.MultiLinePercent;
//entity.LineDiscount = purchaseJournalTransaction.LineDiscount;
//entity.LinePercent = purchaseJournalTransaction.LinePercent;
//entity.TaxGroup = purchaseJournalTransaction.TaxGroup;
//entity.TaxItemGroup = purchaseJournalTransaction.TaxItemGroup;
//entity.OriginalPurchId = purchaseJournalTransaction.OriginalPurchId;
//entity.DeliveryDate = purchaseJournalTransaction.DeliveryDate;
//entity.InventDimId = purchaseJournalTransaction.InventDimId;
//entity.InventQuantity = purchaseJournalTransaction.InventQuantity;
//entity.LineAmountTax = purchaseJournalTransaction.LineAmountTax;
//entity.LineHeader = purchaseJournalTransaction.LineHeader;
//entity.RecVersion = purchaseJournalTransaction.RecVersion;
//entity.RecId = purchaseJournalTransaction.RecId;
//entity.Dimension4 = purchaseJournalTransaction.Dimension4;
if
( entity.ApprovalStatus != purchaseJournalTransaction.ApprovalStatus)
{
entity.ApprovalUserId = User.Identity.GetUserId();
entity.ApprovalDate = DateTime.Now;
entity.ApprovalStatus = purchaseJournalTransaction.ApprovalStatus;
entity.Source = ApprovalSource.Web;
//entity.ApprovalReasonId = purchaseJournalTransaction.ApprovalReasonId;
};
//db.PurchaseJournalTransactions.Attach(entity);
db.Entry(entity).State = EntityState.Modified;
db.SaveChanges();
}
else
{
}
return
Json(
new
[] { purchaseJournalTransaction }.ToDataSourceResult(request, ModelState));
}
[HttpPost]
public
ActionResult Excel_Export_Save(
string
contentType,
string
base64,
string
fileName)
{
var fileContents = Convert.FromBase64String(base64);
return
File(fileContents, contentType, fileName);
}
protected
override
void
Dispose(
bool
disposing)
{
db.Dispose();
base
.Dispose(disposing);
}
}
}